Reputation: 107
Extensive research couldn't answer this question but i feel it's not a big thing:
I aggregate product data and differ at the filter stage, my output (exact same keys) goes into 2 collections.
I work exclusively in mongoshell.
I have only found manuals to bring 2 collections together - with different keys, in this situation i'd use mapReduce to bring them together. what i want is more like classic concat - put all the objects from 2 collections into one.
Upvotes: 1
Views: 149
Reputation: 107
Found a definite answer, exactly what i needed:
use this in mongoshell: db.source_collection.find().forEach(function(obj){ db.target_collection.insert(obj) });
easy, quick, excellent solution!
src: https://wrtsprt.wordpress.com/2011/08/17/merging-collections-in-mongodb/
Upvotes: 1