Faris Shomali
Faris Shomali

Reputation: 137

How to delete a specific array element in firebase collection?

I have list of appointments stored in firebase collection, how can I delete a specific appointment ?

enter image description here

Upvotes: 4

Views: 744

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598668

If you know the exact value for each field of the array item, you can use FieldValue.remove to remove that item from the array.

If you don't know all values of the item, the only way to remove the item is to:

  1. Load the document into your application code.
  2. Get the entire array from the document.
  3. Remove the item from the array.
  4. Write the entire array back to the document in the database.

Upvotes: 5

Related Questions