Is there any way to fetch a collection by giving an initial model parameter to fetch().
To clear out: I have a model Human with attributes name (as a string) and numbers(array). I would like to find all the people in my database with given array of numbers. (Example: I have [123,342,4] in my array and for each number I would like to pull the people's name).
I've created a Human collection giving the model is human. And when I fetch like this it causes no problem;
humanCollection.fetch({
success:function(model,response){
console.log(model.toJSON().length);
var arr=model.toJSON();
for(var i=0;i<arr.length;i++)
console.log(arr[i].humanName+" ");
console.log("Success");
},
error:function(model,response){
console.log(response);
console.log("Failure");
}
});
I'm thinking of creating a dummy human object with no name and just numbers and later on passing the numbers to my php but .fetch() function doesn't seem to work when I put a parameter to the beginning. Not even the code below works;
humanCollection.fetch({},{
success:function(model,response){
console.log(model.toJSON().length);
var arr=model.toJSON();
for(var i=0;i<arr.length;i++)
console.log(arr[i].humanName+" ");
console.log("Success");
},
error:function(model,response){
console.log(response);
console.log("Failure");
}
});
What could be the problem? And is it logical for me to create a dummy human model in order to retrieve a collection of humans with the given numbers. That was the only way I could think of transferring the specific required json data.