Export mongodb aggregation framework result to a new collection

Starting with Mongo 2.6.0 you can do this natively without any additional manipulation.

db.<collection>.aggregate( [
     { <operation> },
     { <operation> },
     ...,
     { $out : "<output-collection>" }
] )

Check the new aggregation operator $out for more detailed example.

P.S. using this way you are not limited to 16Mb size.

Leave a Comment