Firestore doc Update with Merge true using Admin SDK creates new document?

567 views
Skip to first unread message

Deependra Solanky

unread,
Apr 1, 2020, 10:54:11 AM4/1/20
to Firebase Google Group
Last week while working on Cloud Firestore using Admin SDK, I accidentally forget to replace .update with .set with merge true option and to my surprise the query worked and document got created. I removed merge:true and then I got document not exists error. I tested it again with merge:true and document created again. I could not find anything about this in documentation. Requesting Firebase team to explain this behaviour. I posted this on stackoverflow (https://stackoverflow.com/questions/60899399/firestore-doc-update-with-merge-true) but I was advised to post here.

let query = userRolesRef .doc(user).update( { isDeliveryPerson:true }, { merge: true } );

Kato Richardson

unread,
Apr 1, 2020, 1:25:23 PM4/1/20
to Firebase Google Group
Hello Deependra,

The API reference is essentially the contract for what behavior you should expect; that's here. Given that the behavior doesn't match that, and assuming you're on the latest SDK version, this should be filed as a bug in the GitHub repo.

Thanks for finding this and sharing!

☼, Kato



On Wed, Apr 1, 2020 at 7:53 AM Deependra Solanky <sol...@gmail.com> wrote:
Last week while working on Cloud Firestore using Admin SDK, I accidentally forget to replace .update with .set with merge true option and to my surprise the query worked and document got created. I removed merge:true and then I got document not exists error. I tested it again with merge:true and document created again. I could not find anything about this in documentation. Requesting Firebase team to explain this behaviour. I posted this on stackoverflow (https://stackoverflow.com/questions/60899399/firestore-doc-update-with-merge-true) but I was advised to post here.

let query = userRolesRef .doc(user).update( { isDeliveryPerson:true }, { merge: true } );

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/754eb1e8-ab3c-4fd1-a2ea-8e1c33196c83%40googlegroups.com.


--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Reply all
Reply to author
Forward
0 new messages