// Find user who has the first_name equal with "name" (case insensitive)
const users = await User.find({
first_name: {
$in: [new RegExp(`^${name}$`, 'i'))]
}
})
var search ='Neha';
db.members.find(name: new RegExp(search)) //For substring search, case sensitive.
db.members.find(name: new RegExp('^' + search + '$')) //For exact search, case sensitive
db.members.find(name: new RegExp(search, ‘i')) //For substring search, case insensitive
db.members.find(name: new RegExp('^' +search + '$', 'i')); //For exact search, case insensitive
{ <field>: { $regex: /pattern/, $options: '<options>' } }
{ <field>: { $regex: 'pattern', $options: '<options>' } }
{ <field>: { $regex: /pattern/<options> } }