1.cmd输入limit为字段 skip为下标
//limit(2) 只会获取两条数据
db.top250.find().limit(2)
//skip() 下标
db.top250.find().skip(1).limit(2)
2.前端处理limit和下标
http://localhost:8080/top250?start=0&count=5;
start-->为下标
count-->为限制
3.index.js
router.get("/top250",async ctx=>{
console.log(ctx.query)
var {start,count} = ctx.query
console.log(start)
if(start==undefined){
start = 0
}
if(count == undefined){
count = 5
}
var data = await Top250Model.find({}).skip(Number(start)).limit(Number(count));
ctx.body = {
data,
code:200
}
})