Mongo数据库不等于查询不起作用 [英] Mongo db not equal to query not working

查看:142
本文介绍了Mongo数据库不等于查询不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从mongodb集合中的概述"中选择所有不同的内容.我使用下面的查询,但它不起作用...

I am trying to select all different from "overview" in a mongodb collection. I use the query below but it does not work...

hist = db.find({'type':{$ne:'overview'}})

如果我尝试不使用$ ne,它会起作用...

If I try without the $ne it works...

关于什么是错的任何想法?

Any ideas on what is wrong?

谢谢!

更新

只需修复...就必须引用"$ ne"

Just fixed... had to quote the "$ne"

推荐答案

由于pymongo使用dict作为参数,因此需要在$ne周围加上引号.由于$ne不是变量,因此无法解释{ $ne : 'overview' }.长话短说,试试这个:

You need to put quotation marks around $ne since pymongo uses dicts as parameters. It can't interpret { $ne : 'overview' } since $ne isn't a variable. Long story short, try this:

hist = db.find({'type':{'$ne':'overview'}})

这篇关于Mongo数据库不等于查询不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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