0

I have this Firestore very basic document object named 'index' : {index: [{name: "Book"}]}

I want to update the field 'name' incrementally using this code :

await docRef.update({'index.0.name': 'Book2'})

But the result is: {index:{"0": {name: "Book2"}}}

I lost my array. It there a way to make it works ? this example is very basic, but the principle is to be able to update a single field on a massive array of objects without having to give the whole object with the update or set method every time for a single field update.

Thanks!

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Pierre
  • 21
  • 3
  • There is no way to atomically update a single value in an item in an array. You can either add an item to an array or move items to it. The only alternative is to: 1) read the document into your application code, 2) get the array from it and update it in memory, 3) write the entire array back to the database. – Frank van Puffelen Apr 07 '23 at 03:28

0 Answers0