I read Ember docs and some examples of working with Embedded Object, like JSON in Ember.
I came across a function EmbeddedRecordsMixinand saw that we can write code, as shown below, to report that this is a built-in record.
import DS from 'ember-data';
export default DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
attrs: {
author: { embedded: 'always' },
}
});
Qouting below from the Ember page
Note that this use of {embedded: 'always'} is not related to {embedded: 'always'}, which is defined as an option on DS.attr as part of the model definition when working with ActiveModelSerializer. However, using {embedded: 'always'} as an option for DS.attr is not a valid way to set embedded records.
And I also saw a model written as follows.
App.Child = DS.Model.extend({
name: DS.attr('string'),
toys: DS.hasMany('toy', {embedded: 'always'}),
});
If the child has an inline toy object.
, serailizer, ?
App.ChildSerializer = DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
attrs: {
toys: {embedded: 'always'}
}
});
- {embedded: 'always'} , ?