I'm trying to do a find (with ember-data) on other params than the id, two params actually.
but all i get back is:
"Uncaught Error: assertion failed: Your server returned a hash with the key customer but you have no mappings".
After digging around in the code i see that the find method delegates to the findQuery method when given an hash, which create a DS.AdapterPopulatedRecordArray but I only return a single customer object in my json:
{"customer":{
"id":24857,"name":"Kim Fransman","id_number":"XXXX","email":"[email protected]","type":"Person"}}
I can solve this by wrapping my json in a customers array and looping through them in my handlebars view but that feels very wrong.
Is there a way to do this with ember-data today?
I had a similar issue and I opened a question here. Basically this is an undocumented property of the RESTAdapter that you have to configure according to your models. You'll have to define it similarly to this:
App.Store = DS.Store.extend({
adapter: DS.RESTAdapter.create({
bulkCommit: true,
mappings: {
// All your models will have to have a mapping defined,
// like this...
genres: 'App.Genre'
}
}),
revision: 4
});
Check my question here: Ember-Data: How do "mappings" work
I hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With