问题
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