Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 362
Faris Shomali Avatar asked Oct 19 '25 03:10

Faris Shomali


1 Answers

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.
like image 132
Frank van Puffelen Avatar answered Oct 21 '25 03:10

Frank van Puffelen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!