I'm constructing a Parse.com query inside a Parse query on the browser in a Parse/backbone app.
I have a two stage query (and want the intermediate results) so I construct the second query in a when clause from the first query's fetch:
// changeJob is a backbone event handler triggered from global app state
changeJob: function() {
var taskQuery = new Parse.Query(Task);
taskQuery.equalTo("publicJob", theAppState.get("publicJob"));
taskQuery.equalTo("status", "accepted");
taskQuery.limit(20);
this.tasks.query = taskQuery;
var self = this;
this.tasks.fetch().then(function(foundTasks){
console.log("got " + foundTasks.length + " tasks");
var responsesQuery = new Parse.Query(StepResponse);
responsesQuery.containedIn("task", foundTasks); /// Stack blows here
responsesQuery.include("task");
responsesQuery.include("task.taskLocation");
responsesQuery.limit(1000);
self.responses.query = responsesQuery;
console.log("fetch the step responses");
self.responses.fetch();
});
My collections are model objects are declared with global scope:
var StepResponse = Parse.Collection.extend("StepResponse", {
});
// StepResponse Collection
var StepResponseCollection = Parse.Collection.extend({
model: StepResponse,
});
var Task = Parse.Object.extend("Task", {
});
// Task Collection
var TaskCollection = Parse.Collection.extend({
model: Task,
});
When I try to restrict the inner query based on using the array from the first query, I get a Maximum Stack size exceeded error.
I've seen a few people discuss this on SO but I don't think that they are duplicates - I don't have any bi directional links between these two classes and the stack blows when I'm setting up the query, before I execute it of try to save any objects.