MONGOC_CURSOR_SET_LIMIT(3)

✨ MONGOC_CURSOR_SET_LIMIT(3) ✨

okay bestie, welcome to the libmongoc manual page for mongoc_cursor_set_limit β€” she's giving "small function, big personality" and honestly? iconic πŸ’…


🌸 SYNOPSIS 🌸

bool
mongoc_cursor_set_limit (mongoc_cursor_t *cursor, int64_t limit);

πŸŽ€ PARAMETERS πŸŽ€

  • cursor β€” a mongoc_cursor_t. your main character ✨
  • limit β€” the maximum number of documents to retrieve for this query. signed, so she can go negative too πŸ‘‘

πŸ¦‹ DESCRIPTION πŸ¦‹

So what does she do? She limits the number of documents in the result set. That's the whole vibe. πŸ“

This function is genuinely so useful for setting the limit on a cursor after the cursor is created, but before any calls to mongoc_cursor_next(). Lowkey the perfect little window to slide in and set your limit πŸ’–

It can also be used to pass a negative limit β€” yes bestie, the limit parameter to mongoc_cursor_set_limit is signed, so negatives are fair game 😌

⚠️ Calling this function after mongoc_cursor_next() has no effect. she's done listening at that point, fr fr πŸ’€

And here's the tea: 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. like, at all. she simply doesn't apply there 🧚

🌈 RETURNS 🌈

Returns true on success. If any arguments are invalid, returns false and leaves the limit unchanged β€” no funny business, she keeps the original value 🫢

πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc

2009-present, MongoDB, Inc.


and that's the whole page, bestie! πŸ’œ ngl she's short but she ate ✨ remember: set your limit before the mongoc_cursor_next() calls, keep it signed, and don't come for the database-listing cursors because they're not playing that game πŸŽ€

this cute little sign-off is version 2.5.6, dated Oct 09, 2026, straight from libmongoc β€” MONGOC_CURSOR_SET_LIMIT(3), slay πŸ’…πŸŒΈ

πŸ“¦ where this page comes from