如何从数组中删除重复的条目? [英] How to remove duplicate entries from an array?

查看:82
本文介绍了如何从数组中删除重复的条目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的示例中,"Algorithms in C++"出现两次.

In the following example, "Algorithms in C++" is present twice.

$unset修饰符可以删除特定字段,但是如何从字段中删除条目?

The $unset modifier can remove a particular field but how to remove an entry from a field?

{
  "_id" : ObjectId("4f6cd3c47156522f4f45b26f"), 
  "favorites" : {
    "books" : [
      "Algorithms in C++",    
      "The Art of Computer Programming", 
      "Graph Theory",      
      "Algorithms in C++"
    ]
  }, 
  "name" : "robert"
}

推荐答案

您要做的是使用map reduce来检测和计数重复的标签.然后使用$set替换基于{ "_id" : ObjectId("4f6cd3c47156522f4f45b26f"),的整本书

What you have to do is use map reduce to detect and count duplicate tags .. then use $set to replace the entire books based on { "_id" : ObjectId("4f6cd3c47156522f4f45b26f"),

这里已经讨论过旅行时间..请参见

This has been discussed sevel times here .. please seee

使用MapReduce删除重复记录

在以下位置的索引列上查找重复项的快速方法mongodb

http://csanz.posterous.com/使用mongodb-mapreduce查找重复项

http://www.mongodb.org/display/DOCS/MapReduce

How to remove duplicate record in MongoDB by MapReduce?

这篇关于如何从数组中删除重复的条目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆