Suppose I have the following models:
DS.Model.extend({
products: DS.hasMany('product')
});
DS.Model.extend({
customer: DS.belongsTo('customer')
});
And I need to create a client with a list of products by identifiers ( which are not yet loaded from the backend ), something like this:
this.get('store').createRecord('customer', {products: [1, 2, 3]});
But this fails, as the store expects the products to be an array of DS.Model:
Error processing route: index Approval error: all elements of the hasMany relation must be DS.Model instances, you passed [1,2,3]
How to create a record with your associations provided by identifiers?
source
share