How to organise a many to many relationship in MongoDB

What I’ve seen done, and what I currently use are embedded arrays with node id’s in each document. So document user1 has property groups: [id1,id2] And document group1 has property users: [user1]. Document group2 also has property users: [user1]. This way you get a Group object and easily select all related users, and the same … Read more

Delete a key from a MongoDB document using Mongoose

In early versions, you would have needed to drop down the node-mongodb-native driver. Each model has a collection object that contains all the methods that node-mongodb-native offers. So you can do the action in question by this: User.collection.update({_id: user._id}, {$unset: {field: 1 }}); Since version 2.0 you can do: User.update({_id: user._id}, {$unset: {field: 1 }}, … Read more