2016-08-04 117 views
0

我整合自动完成搜索,但我还是坚持,我怎么能avoide重复的项目,而搜索猫鼬avoide与查找查询复制

Deal.find({ 
      title: _keyword 
     }) 
     .distinct("title") 
     .select("title") 
     .limit(10) 
     .exec(function(err, deals) { 
      deffered.resolve(deals); 
     }); 
+0

你能编辑你的问题来解释更多关于你想达到什么?您的要求不明确。 – Shrabanee

+0

我想整合谷歌自动完成搜索,我在我的数据库中有一些交易,其中一些有类似的名称。现在我想如果我找到一些正则表达式的交易,它不应该返回重复交易。 – Kashif

+0

你有没有试过[$ regex](https://docs.mongodb.com/manual/reference/operator/query/regex/)? – Shrabanee

回答

1

试试这个:

Deal.distinct('title') 

看到的不同的文件:

doc

+0

感谢它的工作。 – Kashif