MongoDB查询

xiaoxiao2021-02-28  37

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\./}}}})
转载请注明原文地址: https://www.6miu.com/read-2627074.html

最新回复(0)