MongoDB mongoose 正则匹配

Unknow user · July 15, 2014 · 8418 hits
var regex = new RegExp(sSearch, 'i');
User.find({name: regex}).exec(function (err, items){
}

name 的 type 是 String,这样是可以的;如果换成 age,age 的 type 是 Number,就报类型转换错误 CastError: Cast to number failed for value "/(?:)/i" at path "age",请问一下,该是怎么样的写法?

No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.