Osama
Osama

Reputation: 523

Firestore delete an index inside an array

i am trying to delete an index inside array

this is the data structure enter image description here

I want the user to delete the selected car so it could be index 0 or whatever

Upvotes: 1

Views: 204

Answers (1)

Ali Bayram
Ali Bayram

Reputation: 7921

My opinion is fetch the document and delete the item at which index you want from the local array and update the remote document. Or you can use .document('docID').updateData('cars': FieldValue.arrayRemove([{the-item-map}]));. Maybe there are other options but these two options are acceptable, I prefer to use first one.

Upvotes: 2

Related Questions