ember.js - Ember {embedded: 'always' } on model Vs Serializer -
i reading through ember docs , examples on working embedded object json in ember.
i came across embeddedrecordsmixin
feature , saw can write code below tell embedded record.
import ds 'ember-data'; export default ds.restserializer.extend(ds.embeddedrecordsmixin, { attrs: { author: { embedded: 'always' }, } });
qouting below ember page
note use of { embedded: 'always' } unrelated { embedded: 'always' } defined option on ds.attr part of defining model while working activemodelserializer. nevertheless, using { embedded: 'always' } option ds.attr not valid way setup embedded records.
and have seen model written this.
app.child = ds.model.extend({ name: ds.attr('string'), toys: ds.hasmany('toy', {embedded: 'always'}), });
where child object has toys object embedded.
going first example, can write child serailizer below?
app.childserializer = ds.restserializer.extend(ds.embeddedrecordsmixin, { attrs: { toys: {embedded: 'always'} } });
can me understand difference between these 2 {embedded: 'always'}
, use when?
thanks
Comments
Post a Comment