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 framework return result sets of any size.
refrences [https://docs.mongodb.com/manual/reference/operator/aggregation/out/]
db.Product.aggregate({"$match":{price:10.11,comments:"Good!"}},{"$out":"outProduct"})
> show tables
Product
orders
outProduct
system.indexes
> db.outProduct.find()
{ "_id" : ObjectId("57063058e70eccec158b4567"), "name" : "A foo bar", "price" : 10.11, "did" : NumberLong(44), "comments" : "Good!" }
{ "_id" : ObjectId("57172e93e70ecc86538b4567"), "name" : "A foo bar", "price" : 10.11, "did" : NumberLong(82), "comments" : "Good!" }
网友评论