Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch set with merge option

Is there a batch method corresponding to the javascript set with merge option?

I was looking at the documents, but couldn't find anything on this. If not, what is the current official approach to merging items in a batch?

like image 294
uksz Avatar asked May 09 '18 06:05

uksz


2 Answers

After some time, I found out that you can achive that using:

batch.set(db.doc(t.ref.toString()), { field: admin.firestore.FieldValue.delete() }, { merge: true }))
like image 83
uksz Avatar answered Sep 22 '22 19:09

uksz


If you're using Python just use: batch.set("path/to/document", data, merge=True)

Firebase documentation - addition of data says that we can add a parameter "merge=True" for setting with merge. The same applies to batch updates and works fine when tested on Python3.

like image 45
Saurabh Avatar answered Sep 21 '22 19:09

Saurabh