3 ms·
In real life you would have a users collection and an events collection, and the events field of users would be an array of event ids.
by rabidsnail 16y ago
In real life you would have a users collection and an events collection, and the events field of users would be an array of event ids.
- angilly 16y agoMy first response was "not necessarily," but I'm gonna ratchet it up a notch to a flat out "you're wrong." Storing event_ids as an array in the events field defeats the whole purpose of organizing your data into rich documents. In real life, you very well could build something where the events info was built straight into the user record.
- deleted 16y ago[deleted]
- sv123 16y agoseems like a relational database to me...only without the ability to join?
- kchodorow 16y agoSort of. MongoDB tried to keep a lot of the trimmings of a relational database, but remain scalable. Joins are handy, but don't scale well.
- mathias_10gen 16y agoActually it would probably be best to reverse the relation and put user_id's in the event objects. Then you can do queries like this: db.events.find({hosted_by: MY_ID}) db.events.find({invited: MY_ID}) // invited is an array of users