For someone like me (mechanical engineer self-learning swift) is JS very unreadable, indeed. I’m looking through the cloud docs, but I can’t figure out why my further extension of your function does not work:
Parse.Cloud.afterDelete(Parse.User, ({object, log}) => {
const query = new Parse.Query(Parse.Session);
query.equalTo("user", object);
query.find({useMasterKey: true}).then((sessions) => {
return Parse.Object.destroyAll(sessions, {useMasterKey: true});
}).catch((error) => {
log.info(`Error finding related session ${error.code}: ${error.message}`);
});
//setting profile status to "deleted", before it gets cleaned after 30 days
const profileQuery = new Parse.Query("PrsProfile");
profileQuery.equalTo("objectId", object.id);
profileQuery.first({useMasterKey: true}).then((profile) => {
log.info(`to be marked as delete: ${profile}`);
profile.set("stts", 3);
return profile.save({useMasterKey: true});
})
.catch((error) => {
console.error("Error while setting profile status to delete " + error.code + " : " + error.message);
});
});
What I want to achieve is that after user deletes his account, his profile object changed a status field to different value, letting other know that was deleted. This is closest I could get, getting error that shows that it at least tries to write something:
Error while setting profile status to delete 119 : Permission denied for action addField on class PrsProfile.
there is already field “stts” in the class, so there might also be some wrong syntax. If you would spot anything wrong I would appreciate a little help!
Thank you!