Reputation: 47
I've created two collections one for people details and another for their income, spending amount etc.
i want cumulative result how to combine both collections??
Upvotes: 0
Views: 1860
Reputation: 1105
Instead of combining them into one collection (which may or may not be correct in your situation - no way of knowing) take a look at this StackOverflow. Also you should seriously study both the lookup and aggregation possibilities in MongoDB. Since Mongo is NoSQL the way we approach lookup information is a bit different.
Upvotes: 0
Reputation: 194
You can insert all documents from one collection into another. Here is how to do that using the mongo shell:
db.collection1.find().forEach( function(x){db.collection2.insert(x)} );
Upvotes: 2