mongoDB $out (aggregation)

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!" }
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 昨天回来休息了一整天,觉得还是累。 今天早起坐享,坐着感觉快要睡着了。及时调整呼吸,不胡思乱想。坚持了15分钟。 ...
    雨枫英语阅读 160评论 2 0
  • 阳光穿不透厚厚的云层 卡车隆隆的噪音阻隔了我想象的视野 所以连我编的故事 都变得不那么通达合理 老情人喂我吃了一勺...
    租了五颗星阅读 225评论 0 2
  • 有一天,大明王朝的最后一个皇帝朱由校坐在朝堂上,听过他的首辅和别的大臣的汇报,问了东南各省的旱情和宁远防线上对后金...
    柳梦梅阅读 474评论 3 0
  • 事情,暂时这样落幕了。突然出现的老人,苗天华也告诉了我他的身份,曾经。这个人统治了整个市区,乃至…市区周围,包括那...
    浮生万梦星耀烛天阅读 281评论 0 1