I'm currently running the Parse cloud code background job, which involves querying all users and then running a number of functions for every user object that's returned. How do I set the query to only return the first ______ user objects, rather than all of them?
I know that if you wanted to only return the first result you'd do return usersQuery.first
instead of return usersQuery.each
. Is there an equivalent that only returns the first X number of results?
Parse.Cloud.job("mcBackground", function(request, status) {
// ... other code to setup usersQuery ...
Parse.Cloud.useMasterKey();
var usersQuery = new Parse.Query(Parse.User);
return usersQuery.each(function(user) {
return processUser(user)
.then(function(eBayResults) {
return mcComparison(user, eBayResults);
});
})
.then(function() {
// Set the job's success status
status.success("MatchCenterBackground completed successfully.");
}, function(error) {
// Set the job's error status
status.error("Got an error " + JSON.stringify(error));
});
});