Navigation
This version of the manual is no longer supported.

cursor.limit()

cursor.limit()

Use the cursor.limit() method on a cursor to specify the maximum number of documents the cursor will return. cursor.limit() is analogous to the LIMIT statement in a SQL database.

Note

You must apply cursor.limit() to the cursor before retrieving any documents from the database.

Use cursor.limit() to maximize performance and prevent MongoDB from returning more results than required for processing.

A cursor.limit() value of 0 (e.g. “.limit(0)”) is equivalent to setting no limit.