Triggers after creating an object in cloud code
Objects created through cloud code no longer triggers beforeSave and afterSave handlers for that object.
They should, since cloud code uses the client methods and calls back in to the server... Did you make sure to change the Parse.serverURL to point to your API server in cloud code? (We do need to document this better.)
This is the settings I have. Is this what you refer as the Parse.serverURL?
var api = new ParseServer({
databaseURI: 'mongodb://localhost:27017/db',
cloud: '/Users/alai/dev/cloud/main.js', // Provide an absolute path
appId: 'xxxxxxxx',
masterKey: 'yyyyyyyy',
facebookAppIds: [ 'zzzzzzzzzzzz' ]
// fileKey: 'optionalFileKey'
});
// Serve the Parse API on the /parse URL prefix app.use('/parse', api);
For me, the beforeSave/afterSave triggers get called from iOS sdk when an object is modified, but the triggers are not called in my cloud code (main.js) when an object is modified there.
I think this is the reason: https://github.com/ParsePlatform/parse-server/issues/131
Actually, it looks like the objects I try to create in cloud code through object.save() does not get created in MongoDB. This maybe the root cause of why the triggers are not executed.
For example:
var createLog = function(object) { Parse.Cloud.useMasterKey(); var log = new Parse.Object('Log'); var acl = new Parse.ACL(); log.setACL(acl); log.set('objectClassName', object.className); log.set('action', object.get('lastAction')); log.save(); console.log('Log created for ' + className); };
The console.log('Log created for ' + className); shows up in the console, but the record is not created in MongoDB.
Your Cloud Code is probably trying to save an object against parse.com and either saves it successfully or silently fails depending on whether app with the same appId exists there.
@r4zzz4k how do I set it to my own localhost than parse.com?
@r4zzz4k Yes, you are correct, the object get saved in Parse.com! How to modify this behavior?
Here is how I've managed to overcome this issue on my server: https://github.com/ParsePlatform/parse-server/pull/132
Closing this issue as duplicate as the root cause is issue #132