Skip to content Skip to sidebar Skip to footer

Cloud Firestore: Update Field Values In Nested Array Object With Dot Notation

Please help me solve this, I would like to update the fields using dot notation, using set() but each time I run with the below implementation. I have the fields added to firestore

Solution 1:

It is indeed not possible to update a single element in an array using dot notation, or otherwise. To update an array you'll need to:

  1. Read the document
  2. Get the current value of the array from it
  3. Determine the new array contents
  4. Write the entire updated array back to the database.

The only alternative array operations are array-union and array-remove, which add and remove unique elements to/from the array - essentially treating it as a mathematical set. But since you are looking to update an existing element, these operations are of no use here.

Also see:


Post a Comment for "Cloud Firestore: Update Field Values In Nested Array Object With Dot Notation"