Pymongo 使用 $exists [英] Pymongo using $exists

查看:78
本文介绍了Pymongo 使用 $exists的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 pymongo 的新手,在使用exists 时遇到了问题.使用 collection.find({},{"cwc":{"$exists": True}}) 时出现以下错误 Unsupportedprojection option: $exists

I'm new to pymongo and having trouble using exists. When using collection.find({},{"cwc":{"$exists": True}}) I get the following error Unsupported projection option: $exists

我想要完成的是找到所有_id"和cwc",其中cwc"存在且不为空.

What I'm trying to accomplish is to find all '_id' and 'cwc' where 'cwc' exists and not empty.

推荐答案

collection.find({"$and":[ {"cwc":{"$exists": True}}, {"cwc":{"$ne": ""}}]})

这篇关于Pymongo 使用 $exists的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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