2

I have been trying to add data to sections in my firestorm database, I have a collection -> document -> data fields. Whenever I use setData({'key': 'value'}) is always overwrites the data already in the document. Is there anyway around this?

2 Answers 2

4

That is because what setData(object) is used for

To create or overwrite a single document

While update(object)

To update some fields of a document without overwriting the entire document

So what you need is to use update()

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, Ill be sure to use that. But I figured out what I really needed to do was setup a collection inside the documents.
4

Using merge: true in your setData() statement prevents overwrite. This seems similar to the update() method but you can use it even when document does not exist (ie is being created).

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.