How to write model in ember with many to many relation like this?
Patron
- hasMany Events (as Events patron go)
- belongTo Event (as who attend the Event)
Event
- belongTo Patron (as what event patron go)
- hasMany Patron (as Event attendees)
currently i write it like this, is this correct?
Event
export default DS.Model.extend({
attendees: DS.belongsTo('patron', {
async:true,
inverse: 'events'
}),
attendees: DS.hasMany('patron', {
async:true,
inverse: 'attending'
}),
})
Patron
export default DS.Model.extend({
events: DS.hasMany('event', {
inverse: null
async: true
}),
attending: belongsTo('event', {
async: true,
inverse: 'attendees'
})
})
Aucun commentaire:
Enregistrer un commentaire