4 ms·
Ahh I was not clear. sad trombone In this case, the events in the user document are events that the user is HOSTING. There would be another object in our dat
by angilly 16y ago
Ahh I was not clear. sad trombone
In this case, the events in the user document are events that the user is HOSTING.
There would be another object in our data model to represent the people that got invites to the event. These 'recipients' could be another collection or a list embedded inside each event object.
- sv123 16y agoSo then similarly if I wanted to see all the events that I was invited to would I have to loop through all users, all their events, and all of their invitees to see if I was one?
- angilly 16y agoYou're going to a depth that is testing the limits of my example :) You wouldn't have to do that. You can have deep indexes, and query on those attributes. So if events had invites embedded, and invites all had email addresses for their recipients: db.users.find({'events.invites.email': 'sv123@gmail.com'}) and that would return all the users that had invited you to an event. Now, like I said you're testing my example. When these kinds of requirements are taken into account, you'd probably want to have a separate collection for events. Then you could do: db.events.find({'invites.email': 'sv123@gmail.com'})