Closed
Description
Hello everyone,
first of all thank you for releasing parse-server!
Now on the issue:
Attributes changed on beforeSave
are still not updated, even on Parse >= 2.1.5.
When you call save() on an object on parse-server then beforeSave and afterSave are not triggered.
Environment Setup
"parse": "^1.7.1",
"parse-server": "^2.1.6",
Steps to reproduce
Just create a test class called TestClass
, put the following code in you parse-server main module and call the test
endpoint:
const TestClass = Parse.Object.extend('TestClass')
Parse.Cloud.define('test', (req, res) => {
console.log('test function called')
const test = new TestClass({ name: 'testtesttest' })
test.save()
.then(res.success)
.fail(err => res.error(err.message))
})
Parse.Cloud.beforeSave(TestClass, (req, res) => {
const obj = req.object
console.log('[beforeSave] object: ', obj.toJSON())
obj.set('surname', 'this is not saved')
res.success()
})
Parse.Cloud.afterSave(TestClass, (req, res) => {
const obj = req.object
console.log('[afterSave] object: ', obj.toJSON())
res.success()
})
Logs/Trace
beforeSave and afterSave are not called.
Parse-server console output:
test function called
Client that called the test
function result:
{
"result": {
"name": "testtesttest",
"createdAt": "2016-03-15T07:56:25.711Z",
"updatedAt": "2016-03-15T07:56:25.711Z",
"objectId": "SSXFO5VfxU",
"__type": "Object",
"className": "TestClass"
}
}
If you create a new TestClass object by calling the classes/TestClass endpoint (e.g.: http://localhost:1337/parse/classes/TestClass) beforeSave and afterSave are triggered correctly:
Parse-server console output:
[beforeSave] object: { name: 'testtest' }
[afterSave] object: { createdAt: '2016-03-16T14:24:20.923Z',
name: 'testtest',
surname: 'this is not saved',
updatedAt: '2016-03-16T14:24:20.923Z',
objectId: 'c8runB61Nf' }
API call result:
{
"objectId": "c8runB61Nf",
"createdAt": "2016-03-16T14:24:20.923Z",
"name": "testtest",
"surname": "this is not saved",
"updatedAt": "2016-03-16T14:24:20.923Z"
}
Metadata
Metadata
Assignees
Labels
No labels