0

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??

2 Answers2

2

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)} );
Joseph Milane
  • 184
  • 1
  • 9
0

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.

Community
  • 1
  • 1
twg
  • 1,075
  • 7
  • 11