jackweinbender
jackweinbender

Reputation: 423

Ember-data: this.store.find() range of entries?

I'm trying to figure out a way to retrieve a subset of items based on a range of sequential IDs. In other words, I need to return entries 52-64 as my model. Can I do this with this.store.find()? I can't seem to find anything the documentation about it.

Thanks.

Upvotes: 2

Views: 217

Answers (1)

jackweinbender
jackweinbender

Reputation: 423

So, while I don't know whether you can truly find a "range" with Ember Data, you can pass multiple ids or other attribute properties as an array, which will make a request for all of the items. E.g. this.store.find('entry', {id: [1, 2, 3, 4]}). Therfore, you can just build an array of values that represent your range, and it should work. Something like:

model: function(from, to){
    var items = [];
    for(i = from; i <= to; i++){
        items.push(i);
    }

    return this.store.find('Item', {id: items})
}

Upvotes: 1

Related Questions