Frage

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']})

War es hilfreich?

Lösung

Add quotes around field name and $in operator:

coll.find({'blah': {'$in': ["foo", "bar"]}})
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top