谢谢各位了。这里的问题是没有找到C接口
的分页查询的操作。
英文太渣,在mongoDB的网站上没有发现分页相关的。
http://api.mongodb.com/c/current/tutorial.html
增删查改和计数都有,就是没有发现分页操作的。。。
漂亮男人2017-05-02 09:22:49
The conventional method is:
db.users.find().skip(pagesize*(n-1)).limit(pagesize)
There is also a way with better performance:
db.users.find().limit(pageSize); //第一页
last_id = ... //把最后一个_id存下来
users = db.users.find({'_id'> last_id}). limit(10); //第二页
last_id = ... //更新last_id
PHP中文网2017-05-02 09:22:49
mongodb
Like other databases, you can query the corresponding number of data for paging operations. The official documents also have corresponding instructions, such as mongodb.limit and mongodb.skip. Or you can refer to this Chinese description limit.skip. Hope it helps you
滿天的星座2017-05-02 09:22:49
xxxx.find({'xxx':'xxx'},function(err,rs){
res.json(rs);
}).limit(listnum).sort({'id':-1}).skip((pagenum-1)*listnum);
//listnum is the number of records on a page and pagenum is the page number