在mongodb中从集合中查找前20个文档 [英] Finding first 20 documents from collection in mongodb
本文介绍了在mongodb中从集合中查找前20个文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在一个Jframe上显示集合中的前20条记录,在另一帧上显示下20条记录.我是MongoDB的新手.请提出一个查询以查找前20个和后20个文档.
I want to display first 20 records from collection on one Jframe and next 20 on another frame . I am newbie to MongoDB. please suggest a query to find first 20 and next 20 documents.
推荐答案
在MongoDB shell上,您可以执行以下操作:
On the MongoDB shell you can do:
db.collectionName.find( { city: "London" } ).skip( 20 ).limit( 20 );
显示21至40号文件的结果.
To show the results from document 21 to 40.
请查看限制并跳过:我也强烈建议您阅读一个教程: http://docs.mongodb .org/manual/tutorial/getting-started/
I also strongly suggest you go over a tutorial: http://docs.mongodb.org/manual/tutorial/getting-started/
这篇关于在mongodb中从集合中查找前20个文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文