---
name: "mongoc_cursor_set_limit"
section: "3"
platform: "linux"
package: "libmongoc-doc"
version: "1.30.4-1+deb13u3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/mongoc_cursor_set_limit"
---

# mongoc\_cursor\_set\_limit(3)

## SYNOPSIS

```
bool
mongoc_cursor_set_limit (mongoc_cursor_t *cursor, int64_t limit);
```

## PARAMETERS

- •

  **cursor**: A *mongoc\_cursor\_t*.

- •

  **limit**: The maximum number of documents to retrieve for this query.

## DESCRIPTION

Limits the number of documents in the result set.

This function is useful for setting the limit on a cursor after the cursor is created, but before any calls to *mongoc\_cursor\_next()*. It can also be used to pass a negative limit: The **limit** parameter to **mongoc\_cursor\_set\_limit** is signed, although for backward-compatibility reasons the **limit** parameter to *mongoc\_collection\_find()* is not.

Calling this function after *mongoc\_cursor\_next()* has no effect.

This is not applicable to all cursors. Calling *mongoc\_cursor\_set\_limit()* on a cursor returned by *mongoc\_client\_find\_databases\_with\_opts()*, *mongoc\_database\_find\_collections\_with\_opts()*, or *mongoc\_collection\_find\_indexes\_with\_opts()* will not change the results.

## RETURNS

Returns true on success. If any arguments are invalid, returns false and leaves the limit unchanged.

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
