First of all, thanks for a fantastic library!
I am having some trouble updating an array in my document, using arrayUnion;
note: Just to test the two different versions of the API, I am doing the update operation twice. My imports are as follows:
const firebase = require('nativescript-plugin-firebase')
const fbApp = require('nativescript-plugin-firebase/app')
When I attempt to update my array using a primitive (I have tested string and number), it seems to work fine:
let scan = 1234
console.log('Updating scans with', scan)
driver.update(
{
scans: fbApp.firestore().FieldValue().arrayUnion(scan),
scans2: firebase.firestore.FieldValue.arrayUnion(scan),
}
)
My updated fb store via console:

However, when I change my value to an object, it inserts null instead:
let scan = {foo: "bar"}
console.log('Updating scans with', scan)
driver.update(
{
scans: fbApp.firestore().FieldValue().arrayUnion(scan),
scans2: firebase.firestore.FieldValue.arrayUnion(scan),
}
)
FB Console:

Any idea what I could be doing wrong here?
(I _can_ work around this by JSON.stringify-ing my input, but that seems like a slightly silly solution...)
I am using version 7.7.0 and so far am only testing on Android, so I'm not sure if this is a problem on iOS
Very good question actually.
I have only seen examples where primitives are used (as in your first example). Same for the official docs. So that's why the plugin doesn't expect an object.
I'd love to add it but I need to look at a working example of the web api or the Java / ObjC versions. Are you able to find one?
Yes, I am using the web API on a web application to do something similar, and that seems to be working fine:
const firebase = require("firebase");
firebase.initializeApp({...})
let db = firebase.firestore()
const drivers = db.collection('drivers')
/*
...
*/
let driver = drivers.doc(deviceId)
driver.update(
{
messages: firebase.firestore.FieldValue.arrayUnion(
{
message,
source,
time: Date.now()
}
)
}
)
I can't share much more of my code due to IP, but it should be fairly easy to test this out in a FB connect web application.
Thanks, can you also share how that's stored (a screenshot from the FB console)?
Sure, the results are as expected in the console:

Thanks for those details, that really helped. Pretty sad I can't find any official example of using an object with arrayUnion, but anyway: got it fixed!
On iOS it already worked as expected by the way.
Available in 8.0.0 which will be out later this week(end).
Brilliant, thank you so much! I will keep an eye open and update when the new version comes out, and report back!