Reputation: 26765
I have a model defined as follows:
App.Product = DS.Model.extend({
name: DS.attr('string'),
price: DS.attr('number')
});
The REST endpoint successfully returns products, however, despite also returning a field named 'id' containing an integer alongside name and price, it doesn't allow me to retrieve this ID.
product1 = this.store.find('Product', 1);
console.log(product1.get('name'); // successful
console.log(product1.get('id'); // undefined
(I tried adding id: DS.attr('number')
but Ember doesn't allow this.)
What am I missing?
Upvotes: 0
Views: 988
Reputation: 1079
find
is promise-aware: you should be able to check the id like this:
promise = this.store.find('product', '1').then(function(product) {
console.log(product.get('id'));
});
Also make sure you haven't changed your adapter's primaryKey' property to something other than
id`.
Upvotes: 3