MongoDB: Combine data from multiple collections into one..how?

后端 未结 11 1304
余生分开走
余生分开走 2020-11-22 06:44

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

11条回答
  •  感动是毒
    2020-11-22 07:34

    If 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)
    });
    

提交回复
热议问题