-
Notifications
You must be signed in to change notification settings - Fork 137
Closed
Description
Relations only have their instance created on injection into the store, and server applications generally don't maintain an in-memory store. This has to be worked around with something like:
beforeCreateInstance: function(options, attrs) {
options.relationList
.filter(function(relation) {
return relation.localField in attrs;
})
.forEach(function(relation) {
var toInstantiate = attrs[relation.localField]
definition = store.definitions[relation.relation];
if (Array.isArray(toInstantiate)) {
attrs[relation.localField] = toInstantiate.map(function(item) {
return definition.createInstance(item);
});
}
else {
attrs[relation.localField] = definition.createInstance(toInstantiate);
}
});
}