ember-data-save-relationships
ember-data-save-relationships copied to clipboard
How to serialize a child of a child?
Let's say I have the following models setup:
A -> B -> C -> D
This all needs to be saved at the same time, and can be validated on the server, so if A/B/C/D is invalid, the transaction won't save.
I can save A & B, using the following for a.js:
import JSONAPISerializer from 'ember-data/serializers/json-api';
import SaveRelationshipsMixin from 'ember-data-save-relationships';
export default JSONAPISerializer.extend(SaveRelationshipsMixin, {
attrs: {
b: { serialize: true }
}
});
This now sends A & B to the server.
But how do I also send C & D?
In b.js, I should be able to do:
import JSONAPISerializer from 'ember-data/serializers/json-api';
import SaveRelationshipsMixin from 'ember-data-save-relationships';
export default JSONAPISerializer.extend(SaveRelationshipsMixin, {
attrs: {
c: { serialize: true }
}
});
Hi @joshuataylor did you solved your issue ?
@thomasdurin Nope, ended up using a status field for the parent, then deleting if it didn't. My data could handle that, but can think of so many instances it wouldn't.
Did anyone ever figure this out?