0
votes

So, I'm trying to sideload records in ember-data. My models are something like:

App.Product = DS.Model.extend({
     name: DS.attr('string'),
     category_ids: DS.hasMany('App.Category')
});
App.Category = DS.Model.extend({
    title: DS.attr('string')
});

I'm configuring the sideload feature as follows:

App.store.adapter.serializer.configure(App.Category,
    { 
         sideloadAs: 'categories' 
    });
  1. It works as long the name of my field is "category_ids". Any other name won't work. Is there a way to rename it and keep it working?
  2. Since the configuration is done in the resource/model, it doesn't seem to have any way to sideload records for categories when loading products and NOT sideloading categories when loading "Posts". In case both use the same Category resource. is that right?
1
For the first question, it was my fault. I was sending the wrong JSON keys for ember-data. The second question is still pertinent thought. - Guilherme Aiolfi
What happens to embedded always ? I am having an issue as stackoverflow.com/questions/14896049/… - sudhanshu

1 Answers

1
votes

You maybe able to provide the proper mappings for it in the adapter. I'm not sure though. You should provide a sample of your code to better help you.

App.store = DS.Store.create({
    revision: 11,
    adapter: DS.RESTAdapter.create( {
        mappings: {
            categories: 'App.Category'
        },
    })
});