My question is about the first line of parse cloud function. for example, this function is copy from parse docs:
Parse.Cloud.beforeSave(Parse.User, function(request, response) {
if (!request.object.get("email")) {
response.error("email is required for signup");
} else {
response.success();
}
});
The Parse.User is a parse predefined class. Does that mean this cloud function will be automatically executed when saving a object in this class?
Another question is also about the class. here are two examples of parse cloud function from parse example app Anypic and Parse docs:
Parse.Cloud.beforeSave('Activity', function(request, response) {
var currentUser = request.user;
var objectUser = request.object.get('fromUser');
if(!currentUser || !objectUser) {
response.error('An Activity should have a valid fromUser.');
} else if (currentUser.id === objectUser.id) {
response.success();
} else {
response.error('Cannot set fromUser on Activity to a user other than the current user.');
}
});
Parse.Cloud.beforeSave("Review", function(request, response) {
if (request.object.get("stars") < 1) {
response.error("you cannot give less than one star");
} else if (request.object.get("stars") > 5) {
response.error("you cannot give more than five stars");
} else {
response.success();
}
});
What's the difference between these two cloud function in the first line: the Activity is quoted in single quotation marks but the Review is quoted in double quotation marks. Are they all stands for some parse subclass or something else?