JakeKempo
JakeKempo

Reputation: 590

add object data to existing firebase document

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.

Upvotes: 1

Views: 857

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317362

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

Upvotes: 2

Related Questions