What\'s the equivalent of
App.Person.find({age: 30})
in the new Ember Data?
I.e. how do I get an record array based on an attribute?
There are actually a couple ways of doing this. In this example, the model is "Org", the parameter is all org names with name "AAA":
this.store.find('org', {'name' : 'AAA'})
Or
App.Org.store.find('org', {'name' : 'AAA'})
They would both return the same Ember Promise Array.
To work with individual elements in the array you can do:
this.store.find('org', {'name' : 'AAA'}).then( function(result) {
// do stuff with each result
});
Similarly,
App.Org.store.find('org', {'name' : 'AAA'}).then( function(result) {
// do stuff with each result
});
Everything here and more is shown in this jsbin, so you can compare and play yourself. Don't forget to see the results by opening the console.
Thanks to Mike's comment.
The equivalent method in ember data 1.0.0 beta2 is now:
this.store.find('person', {age: 30})
More info on all the changes can be found here.
Hope it helps.