-1

I have the following document in firebase:

disclaimer: ive tried checking arrayRemove() but i just cant get to work the logic behind it

Document
    ----- creaciones[]
               ------ 1{}
                  -------1
                  -------2
                  -------3
               ------ 2{}
                  -------1
                  -------2
                  -------3
               ------ 3{}
                  -------1
                  -------2
                  -------3

I would like to delete the N "creaciones" element entirely

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441

1 Answers1

0

Cloud Firestore SDKs don't offer a way to delete a list element by index. What you will have to do is read the document into memory, make the change to the array in memory, then update the field back to Firestore. You can do this in a transaction if you are concerned about multiple clients trying to change a shared document in this way.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • so i made a local array with the elements minus the specific index i deleted. should I just update the array of the document? if so, how? because I have more elemnts in the document and I dont want them to be lost – Joaquin ROMERO Aug 04 '19 at 20:30
  • I made it work as you said :D – Joaquin ROMERO Aug 04 '19 at 20:35
  • @JoaquinROMERO how exactly did you make this update? I can't pass an array to ```arrayUnion()``` – uber Jun 17 '20 at 17:08