-
-
Notifications
You must be signed in to change notification settings - Fork 595
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(ParseObject): Add option cascadeSave
to save()
#881
feat(ParseObject): Add option cascadeSave
to save()
#881
Conversation
@RaschidJFR thanks for the PR. Can you please take a look in the failing tests? |
I'm checking it. It seems it could easily be fixed by adding a safe condition here, but it seems strange to me as this line should always return a defined array. So what do you think @davimacedo , should I just do:
|
I'd do something like this:
|
Codecov Report
@@ Coverage Diff @@
## master #881 +/- ##
======================================
Coverage 92.1% 92.1%
======================================
Files 54 54
Lines 5026 5026
Branches 1126 1127 +1
======================================
Hits 4629 4629
Misses 397 397
Continue to review full report at Codecov.
|
Thanks for the suggestion @davimacedo , but if I did that new objects wouldn't be saved at all with this option. So I just added the safe check. It seems to work know. Let me know. |
hum... so your idea is, when cascadeSave set to false, not save updates anymore but still save the creates? It is very confusing in my opinion. |
Well yes. I think new objects must always be saved, otherwise you may run into unexpected broken binds later on. The idea here is to prevent Parse from saving objects you do not explicitly intend to save, but keeping relational data working. Maybe it could become less confusing if we try different more explicit name for the parameter? |
I don't know. In my opinion it should either save everything (if cascade set to true, which is the default) or save only the object which For example:
Now |
Nested objects who have not been saved will be ignored when setting `cascadeSave: true`, so save() will throw "Cannot create Pointer to an unsaved ParseObject".
It makes sense. It should be enough throwing the default error then. |
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.
@RaschidJFR thanks for the contribution!!! Would you be willed to also add some note about this new option in JS Docs? |
Sure. I'm already working on it. What about the api reference? is that automatically generated from the code here? |
Nice! The API reference is already updated: https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Object.html#save :) |
The new feature can be used to prevent cascade saving in nested objects (Only ignores objects that have already been saved previously):
Closes #864