Takes the documents returned by the aggregation pipeline and writes them
to a specified collection. The $out operator must be the last stage in
the pipeline. The $out operator lets the aggregation pipeline return result
sets of any size.
db.getSiblingDB("test").books.aggregate( [
{ $group : { _id : "$author", books: { $push: "$title" } } },
{ $out : "authors" }
] )