Pymongo using $exists

Go To StackoverFlow.com

2

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.

2014-11-12 19:43
by E liquid Vape


2

collection.find({"$and":[ {"cwc":{"$exists": True}}, {"cwc":{"$ne": ""}}]})
2014-11-12 20:08
by E liquid Vape


5

This works for me.

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

The only difference is removed the first argument.

2015-12-23 09:45
by user4395104
Ads