Home > Blockchain >  Unsupported projection option $in in pymongo
Unsupported projection option $in in pymongo

Time:03-07

I tried to use something like this in pymongo:

list(db[collectionName].find({}, {fieldName: {"$in": [value1, value2]}}))

but I get an error that its unsupported projection option. How can I correct it?

CodePudding user response:

When trying to match documents, the conditions go in query predicate and not in projection. So try refactoring the code as shown below:

list(db[collectionName].find({ fieldName: {"$in": [value1, value2]} }))
  • Related