如何实现将 MongoDB中group分组后的结果,再存入到mongo数据库中????
过去多啦不再A梦
过去多啦不再A梦 2017-04-24 15:59:32
0
2
808

先通过mongo中的聚合函数:group()后返回的是DBObject 对象,我想将其存入另一个集合中,怎么办???

过去多啦不再A梦
过去多啦不再A梦

reply all(2)
为情所困

Later, I figured it out myself, just put it directly into a document and insert it into the collection. .

習慣沉默
collection.aggregate([
    {
        '$match': {}
    },
    {
        '$group': {}
    }
], {
    out: 'OtherCollection'
})

Requires MongoDB 2.6+
And every time you go out, the previous data will be erased
If you don’t want it to be erased, insert the structures into a new collection in batches

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template