MongoDB Limit

Blog Author


Published Date

12th October, 2020




  • Share this blog :


The Limit() Method

To limit the records in MongoDB, you need to use limit() method. limit()method accepts one number type argument, which is the number of documents that you want to display. The limit() function in MongoDB is used to specify the maximum number of results to be returned. Only one parameter is required for this 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 the number argument in the 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 the limit() method, there is one more method skip() which also accepts a number type argument and used to skip a number of documents.


The basic syntax of the skip() method is as follows



The following example will only display only the second document.

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

For in-depth understanding click on

About Author


Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills .

Related Blogs

Write For Us