I have multi-tenancy Ember.js at v2.13 where users can belong to one or more organisations.
For performance and data protection reasons, I only want to embed the full org record in the user record in case the user record for the current user is fetched.
For all the other users, the organisations are not embedded, but only the id is included in the orgs property.
How would you achieve this more flexible approach of "sometimes embedding and sometimes not"?
// User model
export default DS.Model.extend({
orgs: DS.hasMany('org', { async: false, inverse: 'members' }),
});
// user serializer
export default RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
isNewSerializerAPI: true,
attrs: {
orgs: { embedded: 'always' }
}
});
Aucun commentaire:
Enregistrer un commentaire