What is the best way to load data from relational model, if backend-api do not include relational attribut?

Hello,

my models are defined as:

var Logbook = DS.Model.extend({
        plate: DS.attr('string'),
        mileageOrigin: DS.attr('number'),
        entries : DS.hasMany('logentry',{async:true})
    }
);
var Logentry = DS.Model.extend({
        mileage: DS.attr('number'),
        logbook: DS.belongsTo('logbook',{async : true}),
        date: DS.attr('string'),
        liter: DS.attr('number'),
        price: DS.attr('number'),
        notice: DS.attr('string')
    }   
);

The API response for Logbook is like this:

logbooks: [
{ 
  Objectid: "76B312AC-182E-4179-9D67-6D3121480E6F",
  mileageOrigin: 100002,
  plate: "XY-AB 23"
}
]

So no attribute entries there. I try to write my own RESTAdapter and RESTSerializer for loading all logentries by loading a logbook, but it seems that all hooks (like extractFindHasMany or findhasMany) are do not trigger, because of the missing attribute.

Does anybody have a tip how to solve this problem? Where ist the best place to handle the relationship between those two models?

Thanks a lot (and sorry for my poor english)

Micha

I think this you need to set the primaryKey property on your logbook serializer.

Hi dpreston,

thanks for your answer. Unfortunatly I did a small mistake:

    logbooks: [
{ 
  id: "76B312AC-182E-4179-9D67-6D3121480E6F",
  mileageOrigin: 100002,
  plate: "XY-AB 23"
}
]

The Backend-API (Microsoft Azure Mobile Service) returns id as attribute. So no extra setting of primary key is needed in serializer.

But my inital problem still exists.