반응형
Mongoose에서 regex를 사용하여 아이템을 찾는 방법
Mongoose doc에서 MongoDb의 $regex에 해당하는 것을 찾지 못했습니다.간단한 몽구스를 제공할 수 있습니까?find()정규 표현으로?
mongoose doc for found.
정규식에 대한 mongodb doc.
var Person = mongoose.model('Person', yourSchema);
// find each person with a name contains 'Ghost'
Person.findOne({ "name" : { $regex: /Ghost/, $options: 'i' } },
function (err, person) {
if (err) return handleError(err);
console.log('%s %s is a %s.', person.name.first, person.name.last, person.occupation);
});
우리가 mongoose에게 건네주는 첫 번째 주장을 주목하세요.findOne 함수."name" : {$regex: /Ghost/, $options: 'i' }}. "name"은 검색 중인 문서의 필드입니다."유령"은 정규 표현입니다."i"는 대소문자를 구분하지 않는 일치에 대한 것입니다.이것이 당신에게 도움이 되기를 바랍니다.
언급URL : https://stackoverflow.com/questions/38497650/how-to-find-items-using-regex-in-mongoose
반응형
'programing' 카테고리의 다른 글
| WordPress 기사 게시 시 작은 문제 발생 (0) | 2023.06.23 |
|---|---|
| write.csv를 사용할 때 행 이름을 파일에 쓰지 않도록 합니다. (0) | 2023.06.23 |
| Vuex, 계산된 속성은 반응성이 없습니다. (0) | 2023.06.23 |
| R로 여러 줄의 댓글을 달 수 있습니까? (0) | 2023.06.23 |
| tslint.json 구성에 포함할 항목은 무엇입니까? (0) | 2023.06.18 |