0

I have the following structure:

COLLECTION_1
---DOC_1
------some_filed: ""
------list (array of maps field)
---------{id: 11, counter: 10}
---------{id: 12, counter: 15}
---------{id: 13, counter: 20}
---------{id: 14, counter: 25}

I am trying to execute firebase increment() on counter field by id.
So if I like to update list item with id 14 by 1.
Can somebody confirm me if thisis possible or I need to fetch document and manually find list item by id update it and update changes back to document?

1110
  • 7,829
  • 55
  • 176
  • 334
  • The only way to update an item in an array in Firestore is to: read the document and grab the array from it, update the item in the app, and then write the entire array back. If you want to perform an atomic update, consider storing he list in a map-field, where you then control the name of each entry. – Frank van Puffelen Aug 01 '22 at 17:49
  • I think that this [resource](https://medium.com/firebase-tips-tricks/how-to-update-an-array-of-objects-in-firestore-cdb611a56073) will also help. – Alex Mamo Aug 02 '22 at 06:32

0 Answers0