Is it possible to have conditional embedding in JSONSerializer
? In my app I have some model relationships I don't wish to include on some pages.
For example:
video detail page this.store.query('video', {filter: {include: 'tags'}})
, here the tags
should be embedded
search results page this.store.query('video')
, here tags should NOT be embedded.
Defining:
import DS from 'ember-data';
export default DS.JSONSerializer.extend(DS.EmbeddedRecordsMixin, {
attrs: {
tags: {embedded: 'always'}
}
});
will always embed tags
into any video
model, and so calling this.store.query('video')
will throw an error because the tags
attribute will not be present in the response.
Aucun commentaire:
Enregistrer un commentaire