mercredi 2 mars 2016

Ember Data merge nested many-to-many relationships

Consider these models:

User

export default DS.Model.extend({
    name: DS.attr('string')
    groups: DS.hasMany('group')

    permissions: Ember.computed('groups.@each.permissions.[]', groups => {
        // What to do here?
    })
})

Group

export default DS.Model.extend({
    name: DS.attr('string')
    permissions: DS.hasMany('permission')
})

Permission

export default DS.Model.extend({
    name: DS.attr('string')
})

How can I get a permissions property on User which contains all Permissions of all Groups?




Aucun commentaire:

Enregistrer un commentaire