Skip to content
Advertisement

How to delete object from array in firestore

I have a problem with deleting an Object out of an Array in firestore. I have this data in firestore:

enter image description here enter image description here

And now I would like to delete e.g the second Object out of the posts Array.

Code:

JavaScript

But I do not know how to define arrayRemove()

These are the pictures and each one has a delete button to delete the picture.

enter image description here

Advertisement

Answer

EDIT: Warning Do not use my solution as it is more than 3 years old, nowadays there is new solution : https://stackoverflow.com/a/59745086/6668441 Mine was a pure js one and is a bad pattern.

Can’t you use filter ? And then return the new posts array to your fb.usersCollection method

JavaScript

edit : So This should be something like :

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement