News for hackers. Stuff that matters.
Re:3 reasons to use MongoDB by sv123 on Thursday September 09, 2010 @02:03PM (#1676225)
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?
Re:3 reasons to use MongoDB by angilly on Thursday September 09, 2010 @02:31PM (#1676339)
You'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': '[email protected]'})

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': '[email protected]'})