반응형

mongoose 에서 like 검색하는 방법: 정규식을 이용한다.

var data = 'Peter'; // 찾을 값

db.User.find({'name' : new RegExp(data, 'i')}, function(err, docs){
// i는 대소문자 무시를 의미 (Case-insensitive search)
});

 

 

 

 

https://masteringjs.io/tutorials/mongoose/find-like

 

`find()` with LIKE in Mongoose

MongoDB does not have a LIKE operator akin to SQL, but MongoDB does support queries by regular expressions. Here's how you can use regexp queries to simulate SQL's LIKE operator in Mongoose.

masteringjs.io

 

반응형