-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
feat: Add Set operation to allow for single key updates #248
Conversation
Thanks for opening this pull request!
|
Codecov Report
@@ Coverage Diff @@
## main #248 +/- ##
==========================================
+ Coverage 76.63% 76.67% +0.04%
==========================================
Files 99 99
Lines 10351 10374 +23
==========================================
+ Hits 7932 7954 +22
- Misses 2419 2420 +1
Continue to review full report at Codecov.
|
Adds two new options to operation:
|
I updated your code to use keyPath's instead. Feel free to keep making updates and let me know when it's ready for review. |
Can you rebase with the main branch? That should get rid of the codecov failure. |
Thanks @cbaker6. I appreciate your help 😊 |
np, I think this should be good to go after merging with main and adding the objectId test case. For the objectId test case, I'm guessing the ParseEncoder should ignore changes in the standard cases. |
One quick question- does edit: I’m assuming your additions solve this |
Yes, mutates target, you can add a test case to be sure |
I think i've added the test cases that you were after - can you let me know if this is what you have in mind? Also, I added a |
Here it returns the mutated target, so you want to compare against, |
Right, thanks!! So if you use operations you should assign I’m assuming that because the SDK isn’t reference types, you have to do this yourself |
I added two more test cases. The mutations on the target is returned after saving, so the developer doesn't need to handle |
Don't forget to add the change log entry |
@dblythy I updated the description some. Feel free to change if you see something that's incorrect. I moved you to the front of the change log since you began the PR. Also, did #248 (comment) answer your question? I'm going to make one more edit to prepare for release. We will wait to your other PR is finished to actually make the release. |
Yep, question answered. I just couldn't figure out how to write the test case to emulate the save op, so thanks for that! No worries, I'll get to the other PR in the next few hours. Thanks again!! |
New Pull Request Checklist
Issue Description
Currently, the solution to only updating one field on an object is to use
emptyObject
#249, which requires the developer to add theemptyObject
property to theirParseObject
manually.Related issue: #242
Approach
This adds a new simple operation of
.set
, so that individual keys can be updated without manually adding a property.Although
.set
is perhaps an artifact of the old SDK, this would allow developers to use.save
to save the whole object, and.operation.set
to update the object, which in my opinion, is a good balance, and provides the reasonable distinction between object.save and object.operation.If we agree on this approach, and I haven't missed any side-effects such as #247, I think we can revertemptyObject
.You can set multiple values at once (
score
andlevels
) and only save modified properties by doing the following:TODOs before merging