mongoose 模糊查查詢

const keyword = ctx.request.body.keyword;
const reg=new RegExp(keyword,'i');//不區分大小寫
objModel.find(conditions, {$or:[
        {name:{$regex:reg}},
        {lyric:{$regex:reg}},
        {singer:{$regex:reg}},
    ]}, { _id: 0,__v:0 }), function (err, doc) {
     if (err) {
            console.log(err);
           } else {
              console.log(doc);
           }
  })
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章