StrongLoop: mutual Model Relations

112 views Asked by At

I have this app with 3 Models: Users, Events and Venues.

An user can create events that take places in a venue, This are the relations:

User: hasMany Event

Venue: hasMany Event

Event: belongsTo User

But I'm not sure if Event must also belongsTo Venue? (as the Venue is not the owner of the Event)


Also, a more advance Question. If I create another Model: Dates... so an Event can have multiple Dates, should I use Events EmbedsMany Dates? or is better to use Events hasMany Dates and Dates belongsTo Event? What's the difference? --> Asked in a new question by request here: StrongLoop: EmbedsMany vs hasMany and belongTo

Thanks in advance!

1

There are 1 answers

0
conradj On BEST ANSWER

I find it useful to think of creating relationships as extending your API endpoints. If you want an endpoint like api/Events/{eventid}/Venue then create the belongsTo relationship to Venue in Event.