In the following cloud code, the first query works fine.
In the chained query, if you include the two lines of code:
query.ascending("createdAt"); // NOTE
query.limit(5); // NOTE
it does not work! if you comment out those two lines of code, it works great. What could be the problem?
It throws no errors, but simply does not execute the .each at all. If you comment out the two lines of code in question, the .each executes perfectly for all results found.
Parse.Cloud.define("someFunction", function(request, response)
{
var query = new Parse.Query("Club");
query.equalTo("objectId", request.params.club);
query.first(
{
success: function(object)
{
return object;
},
error: function(error) {...}
}).then(function(club)
{
var query = new Parse.Query("Player");
query.equalTo("club", club);
query.include("user");
query.ascending("createdAt"); // NOTE
query.limit(2); // NOTE
query.each(function(employee)
{
var teste = employee.get("email")
console.log("teste ... " + teste);
}) ...