Question

In Mongo shell, one can find documents for multiple values in the same field by

coll.find({blah: {$in: ["foo", "bar"]}});

Just wondering how to do this in PyMongo? Tried this but doesn't work:

coll.find({'blah': ['foo', 'bar']})

Était-ce utile?

La solution

Add quotes around field name and $in operator:

coll.find({'blah': {'$in': ["foo", "bar"]}})
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top