ember.js - How to do implement this relationship with ember-data -


i'm working on ember.js project, backed rails 4 api.

now i've relationship i'm not sure how implement ember-data.

i have 2 models: user , event

user can create events, there 1-n relationship between creator , event user can attend events, there m-n relationship between attendees , events

the creator-event relationship returned api creator_id on events , event_ids on creator.

the attendees-events relationship returned api attendee_ids on events , attended_event_ids on attendees.

now, ember-data supports many-to-many relation adding hasmany relations on both ends of relation.

# app.user events: ds.hasmany('app.event') attended_events: ds.hasmany('app.event')  # app.event creator: ds.belongsto('app.user') attendees: ds.hasmany('app.user') 

my problem is, how tell ember-data attendees related attended_events , creator relates events?

ok, never mind, figured out myself, seem work:

# app.user events: ds.hasmany('app.event', as: 'creator') attended_events: ds.hasmany('app.event', as: 'attendees')  # app.event creator: ds.belongsto('app.user') attendees: ds.hasmany('app.user') 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -