We have a model with a number of child models:
// models/parent.js
export default DS.Model.extend({
children: DS.hasMany("child")
});
// models/child.js
export default DS.Model.extend({
parent: DS.belongsTo("parent")
});
The serializer for the parent model is set up using the EmbeddedRecordsMixin
like this:
// serializers/parent.js
export default DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
attrs: {
children: { embedded: "always" }
}
});
If we call save
on an instance of the parent model, will the children be marked as saved? Or do we need to call save on each child model from within the parent model adapter?
Also, if we define a child model serializer, will it get used to serialize the children during the parent serialization process? Or will ED use a default serializer?
Aucun commentaire:
Enregistrer un commentaire