Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Parse.Cloud.job("mcItemCount", function(request, response) {
- // Query all users
- var usersQuery = new Parse.Query(Parse.User);
- // For each user in the DB...
- return usersQuery.each(function(user) {
- //Query all matchCenterItems associated with them
- var matchCenterItem = Parse.Object.extend("matchCenterItem");
- var mcItemQuery = new Parse.Query(matchCenterItem);
- mcItemQuery.equalTo('parent', user);
- // Set the numberOfItems property equal to the # of matchCenterItems they have
- mcItemQuery.find().then(function(results) {
- var numberOfItems = results.length;
- user.set("numberOfItems", numberOfItems);
- });
- }.then(function() {
- // Set the job's success status
- response.success("mcItemsCount completed successfully.");
- status.success("mcItemsCount completed successfully.");
- }, function(error) {
- // Set the job's error status
- response.error('DAMN IT MAN');
- status.error("mcItemsCount FAAAAIIILLED");
- });
- });
- Parse.Cloud.job("mcItemCount", function(request, status) {
- // Query all users
- var usersQuery = new Parse.Query(Parse.User);
- // For each user in the DB...
- return usersQuery.each(function(user) {
- // ...
- }.then(function() {
- // Set the job's success status
- status.success("mcItemsCount completed successfully.");
- }, function(error) {
- // Set the job's error status
- status.error("mcItemsCount FAAAAIIILLED");
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement