Can you edit data in beforeSave callback and if yes, how?
Looking at various docs, it seem like this code should work (using "_User" or Parse.User) and I can see Ran beforeSave on a User and new user! in my logs but the key aaa is still empty..
I've tried to add user.save() after user.set but still no luck.
Any idea?
Parse.Cloud.beforeSave("_User", function(request, response) {
console.log('Ran beforeSave on a User');
var user = request.object;
if(user.existed()) {
response.success();
} else {
console.log('new user!');
user.set('aaa', 'xxx');
response.success();
}
});
EDIT 2015/12/03: Maybe critical info, this code is running on heroku. http://blog.parse.com/announcements/introducing-heroku-parse/
EDIT 2015/12/05: It seem to be a bug with Heroku / Parse integration. beforeSave hook are called but doesn't seem to allow you to edit the request.object..
EDIT 2015/12/07: I've created an issue on the CloudCode-Express repo https://github.com/ParsePlatform/CloudCode-Express/issues/6
request.object.set('aaa','xxx');user.set()function in our code and it works, even if using a local variable. We've had some problems withexisted(), however, and for our use case we can go withif (!user.get('aaa')) {}instead.request.objectdirectly before refactoring a bit.. no luck...