• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

MongoDB Limit

The Limit() Method

To limit the records in MongoDB, you need to use limit() method. limit()method accepts one number type argument, which is number of documents that you want to displayed.

The limit() function in MongoDB is used to specify the maximum number of results to be returned. Only one parameter is required for this function.to return the number of the desired result.

Sometimes it is required to return a certain number of results after a certain number of documents. The skip() can do this job.


Basic syntax of limit() method is as follows



Consider the collection myycol has the following data

{ "_id" : ObjectId(5983548781331adf45ec5), "title":"MongoDB Overview"}
{ "_id" : ObjectId(5983548781331adf45ec6), "title":"NoSQL Overview"}
{ "_id" : ObjectId(5983548781331adf45ec7), "title":"Tutorials Point Overview"}

Following example will display only 2 documents while quering the document.

{"title":"MongoDB Overview"}
{"title":"NoSQL Overview"}

If you don’t specify number argument in limit() method then it will display all documents from the collection.

Learn MongoDB by Tekslate - Fastest growing sector in the industry.
Explore Online MongoDB Training and course is aligned with industry needs & developed by industry veterans.
Tekslate will turn you into MongoDB Expert.


MongoDB Skip() Method

Apart from limit() method there is one more method skip() which also accepts number type argument and used to skip number of documents.


Basic syntax of skip() method is as follows



Following example will only display only second document.

{"title":"NoSQL Overview"}
Please note default value in skip() method is 0

For indepth understanding click on

Review Date
Reviewed Item
MongoDB Limit
Author Rating

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on MongoDB Limit"

Leave a Message

Your email address will not be published. Required fields are marked *

Site Disclaimer, Copyright © 2016 - All Rights Reserved.