mongodb 正则表达式

查询以 李 开头的

 db.student.find({name:/^李/})

查询英文的 姓名

 db.student.find({name:/^[a-zA-Z]{2,10}$/})

 

分页

// db.student.find({}).limit(2)
skip  起始位置
db.student.find({}).skip(2).limit(2)

 

排序    sort  1 正序  2 倒序
db.student.find({}).sort({name:1}) 
db.student.find({}).sort({name:-1})).skip(2).limit(2)

排除重复记录
db.student.distinct("city").slice(0,5)

 

posted @ 2019-08-26 16:48  EricBlog  阅读(1628)  评论(0编辑  收藏  举报