“Regex in Mongo -Abfrage” Code-Antworten

MongoDB $ in Regex

// Find user who has the first_name equal with "name" (case insensitive)
const users = await User.find({
	first_name: {
    	$in: [new RegExp(`^${name}$`, 'i'))]
    }
})
florinrelea

Mongodb Regex

{ <field>: { $regex: /pattern/, $options: '<options>' } }
{ <field>: { $regex: 'pattern', $options: '<options>' } }
{ <field>: { $regex: /pattern/<options> } }
Adorable Angelfish

Regex in Mongo -Abfrage

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
Shankar Anand

Ähnliche Antworten wie “Regex in Mongo -Abfrage”

Fragen ähnlich wie “Regex in Mongo -Abfrage”

Weitere verwandte Antworten zu “Regex in Mongo -Abfrage” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen