I'm using Parse Server on AWS and its been going well. However I am unable to assign ACL as I did in the parse.com cloud code.
I have read The Compatibility Notes, Docs and Git Read me however there is very little mention of ACL.
The following answer has been tried, however it is not working for me.
My old code was like this :
Parse.Cloud.afterSave("Favourites", function(request) {
var user = request.user;
var newACL = new Parse.ACL(Parse.User.current())
newACL.setReadAccess(user, true);
newACL.setWriteAccess(user, true);
request.object.setACL(newACL);
request.object.save();
});
Obviously Parse.User.current() cannot be used which has brought me to this:
Parse.Cloud.beforeSave("Favourites", function(request, res) {
var acl = new Parse.ACL();
acl.setReadAccess(request.object.id, true);
acl.setWriteAccess(request.object.id, true);
request.object.setACL(acl);
res.success();
});
However, this is not working for me.
I have also tried setting the ACL at the same time as saving using the following, however it still doesn't work for me.
var favourites = new Favourites();
var acl = new Parse.ACL();
acl.setReadAccess('request.object.id', true);
acl.setWriteAccess('request.object.id', true);
favourites.setACL(acl);
favourites.save({
user: request.user,
favourites: request.params.favourites
}, {
success: function(favourites) {
console.log('Great!')
},
error: function(favourites, error) {
console.log('The save failed');
}
});
EDIT
I have just tried doing things using the Javascript Docs:
var favourites = new Favourites();
var acl = new Parse.ACL(request.user);
acl.setReadAccess(request.user, true);
acl.setWriteAccess(request.user, true);
acl.setPublicWriteAccess(false);
acl.setPublicReadAccess(false);
favourites.setACL(acl);
favourites.set("favourites", request.params.favourites);
favourites.set("userId", request.user.id);
favourites.set("user", request.user);
favourites.save({}, { useMasterKey: true });
Still doesn't work!
It seems there is a serious lack of node.js cloud code examples in the Docs.
Any help would be greatly appreciated.
Parse.User.current()cannot be used on the nodeJS version of Parse Server see here: blog.parse.com/learn/using-node-js-with-parse - Taylorsuk