Reputation: 4196
I have a document with these param:
"rent": "text",
"leases": [
{
"id": 1,
"title": "text",
},
{
"id": 2,
"title": "text",
}
]
I add new elements to the array like this:
.update({'leases': FieldValue.arrayUnion([newLease])});
But how can I update that id 2 only?
Upvotes: 2
Views: 7246
Reputation: 600006
The array operations can either add an item that isn't in the array yet (FieldValue.arrayUnion
) or remove an item that is in the array already (FieldValue.arrayRemove
). There is no way to atomically update an existing item, by its index or otherwise.
So that means the only option is to:
Also see:
Upvotes: 12