Skip to content

Bug about afterSave hook on increment operation #743

Closed
@wangmengyan95

Description

@wangmengyan95

Make sure these boxes are checked before submitting your issue -- thanks for reporting issues back to Parse Server!

-[ ] You've met the prerequisites.

-[ ] You're running the latest version of Parse Server.

-[ ] You've searched through existing issues. Chances are that your issue has been reported or resolved before.

Environment Setup

Steps to reproduce

Step 1. Create a new ParseObject with a number field like this

 curl -X POST -H "X-Parse-Application-Id: myAppId"   -H "Content-Type: application/json"   -d '{"score":1}'   http://localhost:1337/parse/classes/Game

Step 2. Add a afterSave hook for this class like

Parse.Cloud.afterSave('Game', function(req) {
  console.log(req.object);
  console.log(req.object.get('score'));
});

Step 3. Update the object created in step 1 with an increment operation like

curl -X PUT   -H "X-Parse-Application-Id: myAppId"   -H "Content-Type: application/json"   -d '{"score":{"__op":"Increment","amount":100}}'   http://localhost:1337/parse/classes/Game/XXXX.

Step 4. Check the log of the afterSave hook
The score field is still an operation, not the actual value.

I verify the behaviour of Parse.com, the value we get in the afterSave is a number not the operation.

Logs/Trace

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions