That particular example is actually requesting a collection (all) of something
.
If you are looking for a particular record you would do this.store.find('something', id)
where id is some unique identifier.
this.store.find('something', 3)
this.store.find('something', "cool_post")
App.Something = DS.Model.extend({
someAttr = DS.attr()
});
var promise = this.store.find('something', 2);
promise.then(function(record){
//promise is resolved and the record is ready here
console.log(record.get('someAttr'));
}
find will always return a promise. Ember Data will then asynchronously search it's cache or make a call to the server (or fixture data depending on your adapter). Once the data has return it will then create an instance of something
(defined above). It will then use the serializer associated with the adapter used and apply the results to the instance of something
.
The format your json should come in is like so:
{
"something": {
"id": 1
"someAttr": "Rails is omakase"
}
}
The model hook is a special hook in that if you return a promise to it it will wait and resolve that promise and use the result of the promise instead of the promise for the model of the controller.
See the ember data transition document for additional information: https://github.com/emberjs/data/blob/master/TRANSITION.md