Back
How can I (in MongoDB) combine data from multiple collections into one collection?
Can I use map-reduce and if so then how?
I would greatly appreciate some examples as I am a novice.
To combine data from multiple collections into one there is no bulk insert into mongodb, we loop all objects in the small_collection and insert them one by one into the big_collection:
db.small_collection.find().forEach(function(obj){ db.big_collection.insert(obj) });
db.small_collection.find().forEach(function(obj){
db.big_collection.insert(obj)
});
31k questions
32.8k answers
501 comments
693 users