grahamearley / FirestoreGoogleAppsScript

A Google Apps Script library for accessing Google Cloud Firestore.
http://grahamearley.website/blog/2017/10/18/firestore-in-google-apps-script.html
MIT License
648 stars 109 forks source link

firestore.updateDocument(path, data) erase fields #89

Closed jbenavv closed 4 years ago

jbenavv commented 4 years ago

Hi, I'm not sure if it's a failure, but when I try to update specific fields, it deletes the ones that already exist.

Before: image

var data = { "Spaceid": e.space.name, "Message": input, "Trigger": number, }; firestore.updateDocument(path, data);

Later:

image

LaughDonor commented 4 years ago

You need to pass a third argument with the value of true to not overwrite.

var data = { "Spaceid": e.space.name, "Message": input, "Trigger": number, };
firestore.updateDocument(path, data, true);
jbenavv commented 4 years ago

I found the solution in this case https://github.com/grahamearley/FirestoreGoogleAppsScript/issues/23

Just add a boolean parameter in firestore.updateDocument (path, data, true);

My only suggestion is to add a help example to the new users.

My general opinion as a new user of this library is that it is very good and practical.