I load records into my store in the index route:
model: function(){
return Ember.RSVP.hash({
cars: this.store.query('car',{}).then(function(data){
})
});
}
I then go to my car route to peekAll (no network request) and get all the car records:
model: function() {
return Ember.RSVP.hash({
cars: this.store.peekAll('car').sortBy('name')
});
}
You'll notice I can use 'sortBy' to sort the records based on the field within the local store db.
What I do NOT understand is how to filter or find records from the store? For example, what if I wanted to do the following:
- Sort all car records by Name, and then filter/find the cars so it will only return cars bought in the year 1998 or later
- Filter records, so I only display cars that are 'Jaguars'
- Return only a maximum of 10 records, even if the store has more than 10+ records.
I've looked into findBy and filterBy, but the documentation seems a bit lacking with details on how to implement with examples.
Aucun commentaire:
Enregistrer un commentaire