I’d love to tell you that it worked, but alas…
I read the docs you referred to and used the following afterDelete trigger:
Parse.Cloud.afterDelete(Parse.User, function(request) { Parse.Cloud.useMasterKey(); query = new Parse.Query("Session"); query.equalTo("user", request.object); query.find({ success: function(sessions) { Parse.Object.destroyAll(sessions, { success: function() { console.log("Session deleted") }, error: function(error) { console.error("Error deleting related sessions " + error.code + ": " + error.message); } }); }, error: function(error) { console.error("Error finding related sessions " + error.code + ": " + error.message); } }); });
Notice the “Parse.Cloud.useMasterKey();” that I had to add for the function to execute without errors. I created a test user, deleted it and the the cloud code log said “Session deleted” (as per my console.log printout in the code) but the session was in fact NOT deleted. It was still there. In my face.
I’m really beginning to seriously dislike Parse.
Somehow this seems so strange. I mean, I can’t be the only Parse customer/victim who wants to delete a user? How do you guys do this? I’m starting to think I’m missing something on a more conceptual level here…