Pymongo using $exists

旧城冷巷雨未停 提交于 2020-12-29 12:31:22

问题


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

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


回答1:


This works for me.

collection.find({"cwc":{"$exists":True}})

The only difference is removed the first argument.




回答2:


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


来源:https://stackoverflow.com/questions/26895213/pymongo-using-exists

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!