I’m running into an error trying to load data for a hasMany relationship using a fairly customized serializer. The error is occurring in deserializeRecordId because my related objects are all defined inline instead of sideloaded. Here’s my setup:
I have the following model:
App.ThingHistory = DS.Model.extend({
things: DS.hasMany("thing")
});
I have a legacy endpoint that is giving me a very non-standard response. I’m using a ThingHistorySerializer
(extending JSONSerializer
) and converting it into the following JSON in the normalize callback:
[{
id: 1982348903, // timestamp
things: [{
id: "1982348903_1",
historicalValue1: 92,
historicalValue2: 43
//...
}//, ...]
}]
I know with RESTSerializer
I can do something like:
{
"thing-history": [{
"id": 1982348903,
"things": ["1982348903_1", "1982348903_2"/*, ... */]
}/*, ...*/],
"things": [{/*...*/}]
};
But I’m trying to keep the translation from one format to the other as straightforward as possible and I think this would be more work. I can’t figure out what I need to override in order to make the structure I have work. Can anyone give me any pointers on figuring this out?