Database Managment - Mongo DB

Back to Course

Lesson Description

Lession - #1420 MongoDB Limiting Records

MongoDB – limit(>

In MongoDB, the limit(>
strategy restricts the quantity of records or archives that you need. It essentially characterizes the maximum furthest reaches of records/reports that you need. Or on the other hand as such, this strategy utilizes on cursor to indicate the greatest number of reports/records the cursor will return. We can utilize this technique after the find(>
strategy and find(>
will give you every one of the records or reports in the assortment. You can likewise utilize a circumstances inside find to give you your desired outcome.
  • In this technique, we just pass numeric worth.
  • This technique is indistinct for values which is not exactly - 2131 and more prominent than 231.
  • Passing 0 in this method(limit(0>
    is comparable to no restriction.
Syntax :



Example Consider the collection myycol has the following data.

{_id : ObjectId("507f191e810c19729de860e1">
, title: "MongoDB Overview"}, {_id : ObjectId("507f191e810c19729de860e2">
, title: "NoSQL Overview"}, {_id : ObjectId("507f191e810c19729de860e3">
, title: "Tutorials Point Overview"}

Following example will display only two documents while querying the document.

{"title":"MongoDB Overview"} {"title":"NoSQL Overview"} >
In the event that you don't indicate the number contention in limit(>
strategy then it will show all records from the assortment.

MongoDB Skip(>

Aside from limit(>
technique, there is another strategy skip(>
which likewise acknowledges number sort contention and is utilized to skirt the quantity of archives.
Syntax The basic syntax of skip(>
method is as follows −


Example Following example will display only the second document.

{"title":"NoSQL Overview"} >