mercredi 5 octobre 2022

MangoDB using JavaScript Pattern with $in operator

Trying to create a MongoDB query with the Pymongo driver that search a database for some dog breeds, but I need to do pattern matching due to data being of differing quality. I know I cannot use Regex in a $in style query so I am using JS patterns.

I have this so far:

df = shelter.getRecords({
    "breed": {"$in": [/labrador/i, /chesa/i, /newfound/i]}
    })

But I get syntax errors. Command seems to work in Mongo shell....is this a limitation of Pymongo?

Aucun commentaire:

Enregistrer un commentaire