Mongo数据库不等于查询不起作用

编程入门 行业动态 更新时间:2024-10-25 23:35:52
本文介绍了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数据库不等于查询不起作用

本文发布于:2023-10-23 19:51:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1521847.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不等于   不起作用   数据库   Mongo

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!