In this chapter, we will explain you how to limit records using MongoDB.
Limit() method is used to limit the records in MongoDB. This method accepts one number type argument which is the number of documents which you want to displayed.
Basic syntax of limit() method is as follows
Consider collection myycol has below data.
Below example will display only two documents while querying the document.
If the number argument in limit() method is not specified, then it will display all documents from the collection.
Apart from limit() method, skip() method also accepts number type argument and is used to skip the number of documents.
Basic syntax of skip() method is as follows
Below example will display only the second document.
Remember that the default value in skip() method is 0.
MongoDB Related Interview Questions
|Python Interview Questions||C & Data Structures Interview Questions|
|Hadoop Interview Questions||Node.js Interview Questions|
|Scala Interview Questions||Socket Programming Interview Questions|
|HBase Interview Questions||Solaris Administrator Interview Questions|
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.