0
votes

I have a model and collection, when I create my collection I would like to fetch three models instead of all collections.

If I use collection.fetch() - if will fetch all objects, right now - I am fetching each model and then creating the collection, like this -

var model = new App.Model({ Id: 1 });
model.fetch().success(function() {
    var collection = new Collection(model);
});

(This is a simplistic version for one model, if I want to fetch multiple, I use $.when)

There is an official/better way for doing this? or I am at the good path?

2

2 Answers

1
votes

I think you can get the models that you want from the original collection and put them in a temp collection. So you can fetch the temp collection once instead fetch each model one by one.

0
votes

After a little bit of thinking, I saw that my collections have many to one relation to my model. So I used backbone-relational to fetch all of this collections.