質問

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

役に立ちましたか?

解決

Add quotes around field name and $in operator:

coll.find({'blah': {'$in': ["foo", "bar"]}})
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top