-
Notifications
You must be signed in to change notification settings - Fork 948
Add setDoc() #3139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add setDoc() #3139
Conversation
…irebase-js-sdk into mrschmidt/initializefirestore
This will be tested when getDoc() is added.
8d1219c
to
7649b67
Compare
…-sdk into mrschmidt/deletedoc
…sdk into mrschmidt/snapshot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comment on readability. Otherwise LGTM.
const parsed = isMerge(options) | ||
? dataReader.parseMergeData('setDoc', convertedValue) | ||
: isMergeFields(options) | ||
? dataReader.parseMergeData('setDoc', convertedValue, options.mergeFields) | ||
: dataReader.parseSetData('setDoc', convertedValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional: I like the helper methods you made to interrogate the options but the ternary required effort to parse. Consider factoring this out into a helper function that includes the toMutations()
call or perhaps convert this to a series of if/then/else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have been bothered by this code for a while, as it is repeated in a couple of places in the SDK. I changed UserDataReader.parseSetData() to perform this check on behalf of the caller.
Also adds a lot of tests for existing code and a shared FieldValue class to be used by all SDK versions (comments inline that explain it).