create document only if it doesn't already exists #6596
Unanswered
rahulserver
asked this question in
Feature request
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Based on the comment that closed the issue #1203
"(you can now use SetOptions to achieve the desired behaviour above)"
I don't understand how can we use "SetOptions" https://pub.dev/documentation/cloud_firestore_platform_interface/latest/cloud_firestore_platform_interface/SetOptions-class.html
as a replacement to the .create in the nodejs sdk. ( https://googleapis.dev/nodejs/firestore/latest/DocumentReference.html#create )
The setoptions can only allow us to turn merge:true which will cause the .set to "only replace the values specified in its data argument". This will not fail and throw error like the .create in nodejs. (Hence does not answer the original question which wants to ensure that the document is
never overwritten
)Consequently
.set
withSetOptions
will be less efficient as for ensuring that a doc does not exist, i will have to put a separate query before trying to create a new document.Beta Was this translation helpful? Give feedback.
All reactions