Correct use of $ne or $not in pymongo (unsupported projection option)
You can use the $and
operator to combine requirements like this:
db["mydb"].find(
{"$and": [
{"field": var1},
{"field": {
"$ne": var2
}}
]}
)
Apart from the usage of $and
, you can also fix it by using {}
to combine the filters.
db["mydb"].find({
"field": var1,
"field": {"$ne": var2}
})