1.查询字符串长度
//字符串长度大于1
db.hotelInfo.find({Mobile:{$regex: /^.{1,}$/}})
//字符串长度小于5
db.hotelInfo.find({Mobile:{$regex: /^.{0,5}$/}})
2.匹配集合中的数据
{
"_id":"997285869982195712",
"resGrade":"27",
"resGPS":[
{
"lon":"116.51958",
"lat":"39.93883"
}
],
"countryName":"中国"
}
db.holMidBaseInfo.find({resGPS:{$elemMatch: {lon:{$regex: /116\./},lat:{$regex: /39\./}}}})