Description
Hi,
It seems that the changes into the beforeSave trigger are not propagated to the result of a PUT operation, even if they are correctly saved into the database. I'm not sure if this is the same problem as reported into #1031, because I have it only when I update an object, not when I create it.
Environment Setup
"parse": "^1.7.1",
"parse-server": "^2.1.6",
Steps to reproduce
Suppose you have a class named Book
. Create a beforeSave
trigger that increments a property to 10, each time a book is saved:
// main.js
Parse.Cloud.beforeSave("Book", function(request, response) {
var test = request.object.get("test");
request.object.set("test", test + 10);
response.success();
});
Create a Book like this, on Parse.com and on parse-server:
curl -X POST \
-H "X-Parse-Application-Id: appId" \
-H "X-Parse-REST-API-Key: restApiKey" \
-H "Content-Type: application/json" \
-d '{"title":"The old man and the sea","test":0}' \
http://localhost:1337/parse/classes/Book
Now, update your Book like this, on Parse.com and on parse-server:
curl -X PUT \
-H "X-Parse-Application-Id: appId" \
-H "X-Parse-REST-API-Key: restApiKey" \
-H "Content-Type: application/json" \
-d '{"title":"Don Quichotte"}' \
http://localhost:1337/parse/classes/Book/the_object_id
Logs/Trace
The result of POST on Parse.com:
{
"objectId":"gwMrwEKQ1K",
"createdAt":"2016-03-15T12:14:51.583Z",
"title":"The old man and the sea",
"test":10
}
The result of POST on parse-server:
// OK
{
"objectId":"uH7K8zMfxD",
"createdAt":"2016-03-15T12:04:27.931Z",
"updatedAt":"2016-03-15T12:04:27.931Z",
"title":"The old man and the sea",
"test":10
}
The result of PUT on Parse.com:
{
"updatedAt":"2016-03-15T12:15:13.811Z",
"title":"Don Quichotte",
"test":20
}
The result of PUT on parse-server:
// THE UPDATED FIELD ARE MISSING
{
"updatedAt":"2016-03-15T12:06:13.163Z"
}
In both cases, the properties are correct into the database, but the response of the PUT operation is incomplete with parse-server, whereas it contains all the updated fields with Parse.com.