Parse Cloud code "first" query array returns different results

Viewed 119

I have a simple query as follows :

var getGreaterQuestion = function (gid) {
    var query = new Parse.Query(Parse.Object.extend("Question"));
    query.equalTo("groupId", gid);
    return query.first();
}

I am preparing an array consisting of this function :

var groupIds = _.range(1, 17);
var groupIdAndRandomNumberPack = _.map(groupIds, function (gid) {
   return {groupId: gid, random: Math.random()};
});

var pack = _.map(groupIdAndRandomNumberPack, function (queryItem) {
   return getGreaterQuestion(queryItem.groupId, queryItem.random);
});

In pack array, there are 16 different "first" queries for Question class.

I am running this query using following code snippet :

return Parse.Promise.when(pack).then(function () {
        console.log("arguments : " + JSON.stringify(arguments));
...
...
);

arguments is the result of my query retrieving data from MongoDB.

If I run this query on parse backend, arguments json format is shown as below :

{
   "0":{QuestionObject},
   "1":{QuestionObject},
   ...
   "16":{QuestionObject}
}

If I run this query on my local parse instance with MongoDB defined on MongoLAB, it gives the following result :

{
   "0":[
      {QuestionObject},
      {QuestionObject},
      ....
      {QuestionObject}
   ]
}

What is the reason of this difference? Is there any configuration I need to apply on MongoDB or parse express application for getting the same result as parse backend gives.

1 Answers
Related