-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Save returns objects different from what they are into the database #457
Comments
Maybe it is related to #653 |
Have you tried this with the latest version of |
Sorry, I forgot to mention that I already use the last version of parse-server. |
I'm seeing the same issue. Anytime a value is changed in a beforeSave trigger it is not set on the object passed as a result of the save promise. However the change is set correctly in the database. Here is a minimal example: Parse.Cloud.beforeSave('Person', function(req, res) {
res.object.set('name', 'Anton');
res.success();
});
// Expected behavior is that Anton is printed both times, but William is printed at first
Parse.Cloud.define('changeName', function (req, res) {
var obj = new Parse.Object('Person');
obj.save({name: 'William'}).then(function(obj) {
console.log('From save method: ' + obj.get('name')); // From save method: William
return new Parse.Query('Person').get(obj.id);
}).then(function(obj) {
console.log('From database: ' + obj.get('name')); // From database: Anton
res.success();
});
}); |
Verified this by creating a test inside specs/ParseAPI.spec.js:
Working on a solution, will send a PR. |
We'll fix this with #865 😄 |
After upgrading to parse-server 2.1.5, it works again. Thanks for the fix. |
Hi,
I have a very strange behavior when I save an object, and that I apply a beforeSave trigger on it.
We suppose we have an object with an attribute equal to "100". We also have a "beforeSave" trigger that modifies this value to "50", if some conditions are right.
Now, when I call object.save(), the "beforeSave" is triggered, the value into the database is "50", but the value returned by the "save" operation is still "100".
How is it possible that the "save" operation returns an object with attributes different from what they are into the database?
Thank you.
The text was updated successfully, but these errors were encountered: