zoukankan      html  css  js  c++  java
  • MongoDB数据库去重

    查询:

    db.patents_texts.aggregate([
        {
        $group:{_id:{Patent_num:'$Patent_num',Patent_name:'$Patent_name'},count:{$sum:1}
        }},
        {$match:{count:{$gt:1}}}
       ]);

    删除:

    db.patents_texts.aggregate([
      {
        $group:{_id:{Patent_num:'$Patent_num',Patent_name:'$Patent_name'},count:{$sum:1},dups:{$addToSet:'$_id'}}
      },
      {
        $match:{count:{$gt:1}}
      }
      ]).forEach(function(doc){
        doc.dups.shift();
        db.patents_texts.remove({_id:{$in:doc.dups}});
      });
    人生苦短,何不用python
  • 相关阅读:
    喷水装置(一)
    下沙小面的(2)
    +-字符串
    非洲小孩
    寻找最大数(三)
    C
    寻找最大数
    阶乘之和
    背包问题
    python的内存管理机制(zz)
  • 原文地址:https://www.cnblogs.com/yqpy/p/9190506.html
Copyright © 2011-2022 走看看