Mongodb常用命令、常见问题处理及设置

1. mongodb去重计数

--方法一(容易内存不足报错,加allowDiskUse:true后会出现but there are no result to show)
db.reception.aggregate([
    {limit:100000},
    {group:{_id:"customer_info.customer_name"}},
    {group:{_id:null,count:{sum:1}}}
])

--方法二
db.reception.aggregate([
    {group:{_id:"customer_info.customer_name"}},
    {count:"total_count"}
],{allowDiskUse:true})
Copyright © 2009 - Now . XPBag.com . All rights Reserved.
夜心的小站 » Mongodb常用命令、常见问题处理及设置

提供最优质的资源集合

立即查看 了解详情