Mongodb 删除重复数据
db.getCollection("T_ZXJC_FSSSData").aggregate([ {//聚合字段 $group:{_id:{dwmc:'$dwmc',pfkmc:"$pfkmc",pwxkzbh:"$pwxkzbh",mn:"$mn",xkpfkwybm:"$xkpfkwybm",data_time:"$data_time",sjc:"$sjc"},count:{$sum:1},dups:{$addToSet:'$_id'}} }, { $match:{count:{$gt:1}} //大于1的记录 } ]) .forEach(function(it){ it.dups.shift(); //去掉一个 db.getCollection("T_ZXJC_FSSSData").remove({_id: {$in: it.dups}}); });