I've defined two resources - Foo and Bar - where Foo contains one Bar. However, when inserting some basic data in this format, if multiple Foo's reference the same Bar, then only the most recently loaded Foo is given a reference to it. Previous Foo's have no Bar (it is undefined.)
The resources are defined like so:
DS.defineResource({
name: 'Foo',
relations: {
hasOne: {
Bar: {
foreignKey: 'fooId',
localField: 'bar'
}
}
}
});
DS.defineResource({
name: 'Bar',
relations: {
belongsTo: {
Foo: {
localField: "foo",
localKey: "fooId"
}
}
}
});
And I am injecting the following test data:
var foosJson = [
{
id: 1,
bar: {
id: 100
}
}, {
id: 2,
bar: {
id: 100
}
}, {
id: 3,
bar: {
id: 200
}
}
];
Why does the first Foo not have a reference to the same Bar as the second Foo?
Fiddle with Jasmine tests here: http://jsfiddle.net/dimmreaper/c0o1kqd0/