I am trying to delete all my Parse.com users that have a certain value. So if schoolName == NHS they should be deleted. I have code that might work but I am not confident in it and I would appreciate if someone could help confirm that this should work, and if this is the best way to do it.
Parse.Cloud.job("deleteUsers", function(request, status)
Parse.Cloud.useMasterKey();
var query = new Parse.Query("_User");
query.lessThan("schoolName", "NHS");
query.find({
success: function(result) {
for(var i=0; i<result.length; i++) {
result[i].destroy({
success: function(object) {
status.success("Delete job completed");
alert('Delete Successful');
},
error: function(object, error) {
status.error("Delete error :" + error);
alert('Delete failed');
}
});
}
status.success("Delete job completed");
},
error: function(error) {
status.error("Error in delete query error: " + error);
alert('Error in delete query');
}
});
Thanks!