1

I’m having problems finding the the right approach to adding new data to a Firebase document (using JavaScript)

My document structure is as follows..

Firebase document structure

I want to be able to add a new child (as in kids) and a new class (as in school classes) objects to the children and classes arrays. I tried update, but that just overwrote existing data.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
JakeKempo
  • 580
  • 1
  • 5
  • 14

1 Answers1

2

You can use FieldValue.arrayUnion() to add a new element to an array field of a document.

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