In my ionic 5 application, the following object is behaving differently when I updated the Firestore document directly and in transactions.
let upDoc = {
user: firestore.FieldValue.arrayRemove(this.uid),
["userName." + this.uid]: firestore.FieldValue.delete()
}
So, user is an array and userName is a map. I am trying to remove the user id from the array and remove the user name from the map.
When I do it directly like the following, both get deleted.
this.afs.doc('user/1234/').update(upDoc);
But when I do the same in transaction, only the data from user array gets deleted but userName map data doesn't get deleted.
const doc = this.afs.firestore.doc('user/1234/');
await this.afs.firestore.runTransaction(function (transaction) {
return transaction.get(doc).then(function (document) {
transaction.set(doc, upDoc, {merge: true});
})
});