Mongoose Query to search a document by name when name has any of a set o words no matter order Mongoose Query to search a document by name when name has any of a set o words no matter order mongoose mongoose

Mongoose Query to search a document by name when name has any of a set o words no matter order


You can use $and operator to match both word and $regex to match pattern,

db.collection.find({  $and: [    { name: { $regex: "chess" } },    { name: { $regex: "pasta" } }  ]})

Playground