MongoDB笔记七——分页
1、limit返回数据指定条数
db.persons.find({},{_id:0,name:1}).limit(3)
![MongoDB笔记七——分页](https://app.yinxiang.com/shard/s22/res/1edea0f4-9e20-4d08-957b-1c9b08bbf23e.png)
2、skip返回指定指定数据的跨度
db.persons.find({},{_id:0,name:1}).limit(3).skip(1)
![MongoDB笔记七——分页](https://app.yinxiang.com/shard/s22/res/4aceae57-7133-4a4d-a3f7-e5512e16ab9e.png)
3、sort排序
db.persons.find({},{_id:0,name:1,age:1}).sort({age:1})//递增
![MongoDB笔记七——分页](https://app.yinxiang.com/shard/s22/res/e3dd4484-cf52-44e8-bdb4-b9ece0f913df.png)
db.persons.find({},{_id:0,name:1,age:1}).sort({age:-1})//递减
![MongoDB笔记七——分页](https://app.yinxiang.com/shard/s22/res/5d9f2bcd-06d2-4064-9950-f24684abcce6.png)
分享文章:MongoDB笔记七——分页
文章URL:http://pwwzsj.com/article/gpogjc.html