REST Adapter for non side loading data model


#1

My backend does not produce side loading JSON… Is there an available RESTAdapter to take this into account ?


#2

If your server dos not sideloads objects, you can embed them. See the docs about embedded record mixin


#3

Tx for your help, can you please help me with the following sample, I get an error with this code

App.ShopSerializer = DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {
  attrs: {
    locations: {embedded: 'always'},
  }
});

App.Shop = DS.Model.extend({
  type: attr(),
  name: attr(),
  locations:  DS.hasMany('location'),
});

App.Location = DS.Model.extend({
  altitude: attr(),
  latitude: attr(),
  longitude: attr()
});

JSON looks like: (no root element for the Shop object)

[{type: 'type1', name:'name1', locations: [{altitude: 12, longitude: 3.0, latitude: 2.5}, {altitude: 12, longitude: 3.0, latitude: 2.5}]}]

#4

Any support for this question ?.. I’m blocked on this issue …


#5

In Ember Data, the responsibility for rearranging the data in the server response belongs to the serializer. There’s a very useful post on the subject here.


#6

What if the data is neither sideloaded nor embedded? i.e. just an id returned for the association? I am having problems in that my store is not making another request to fetch the associated record.