4 ms·
So 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
by sv123 16y ago
So 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'})