I'm trying to model a simple event application. Basically:
To many things to think about so it's all mixed up in my head and I'm losing the whole picture. I don't fully understand how I should implement accept/decline Invitation and how I should retrieve information about current participants. What are the relations behind?
I think I know how to do it with references only, but my front-end is mobile so I don't want to make a lot of requests to get every object by reference after the first fetch...
If someone could lighten me up...
Thanks :)
You should have an invitation model and an event model with the following fields.
Invitation : eventId, userInvited, accepted An invitation belongs to an event and belongs to a user
Event : your event details, event owner
Then for a user you can do a remote method that gets the events with
Invitation.find({where: {userInvited: user.id}}, include: 'event')
.then((event) => event.id)
And with the event, gets all the users
.then((eventId) => Invitation.find({where: {eventId}}, include: 'user'))
.then((invitations) => invitations.map((invitation) => invitation.toJSON().user))
It's a quick draft of how to achieve what you want.