MONGOC_CURSOR_NEXT(3)
π MONGOC_CURSOR_NEXT β like, the libmongoc girlies' cursor pagination icon β¨
okay so bestie, welcome to the mongoc_cursor_next page, brought to you by the fine people of libmongoc π«Ά this is the little function that scooches your cursor forward and hands you the next doc. it's giving "next slide please" energy and honestly? iconic.
β¨ SYNOPSIS β¨
bool
mongoc_cursor_next (mongoc_cursor_t *cursor, const bson_t **bson);
that's the whole vibe check right there π
πΈ PARAMETERS πΈ
cursorβ amongoc_cursor_t. yeah. the cursor. the main character. πbsonβ a location for abson_t. like, a spot where the next document can land. give it somewhere to sit down πͺ
π¦ DESCRIPTION π¦
so what does it do? okay so basically this function shall iterate the underlying cursor, setting bson to the next document. slay. that's it. that's the whole thing β¨
highkey important detail: this function is a blocking function. ngl, she will wait. no cap. if you're on a thread that cannot be blocked, this is your heads-up π«Ά
β RETURNS β
this function returns true if a valid bson document was read from the cursor. ate and left no crumbs π
otherwise, it returns false β which happens if there was an error or the cursor was exhausted. yeah, sorry babe, false is doing double duty here π
so how do you tell which one it was? errors can be determined with the mongoc_cursor_error() function. go check on her π§
π LIFECYCLE π
okay so this is the part where you must listen, fr fr π
the bson objects set in this function are ephemeral and good until the next call. ephemeral. like a snapchat streak π
this means that you must copy the returned bson if you wish to retain it beyond the lifetime of a single call to mongoc_cursor_next(). do not be out here holding onto that pointer like it's forever, because it is not π copy it. periodt.
β οΈ bestie i'm serious: thebsonyou get back is only valid until the next call tomongoc_cursor_next(). copy it if you need it to stay. no cap, this is the #1 way people get got π
π AUTHOR π
MongoDB, Inc β the legends themselves π
πΈ COPYRIGHT πΈ
2009-present, MongoDB, Inc. all the rights, all of them π
anyway that's the page!! mwah π this was libmongoc 2.5.6, dated Oct 09, 2026 β go iterate some cursors, bestie, and remember to copy your bson π«Άβ¨
π¦ where this page comes from
- epel 10: mongo-c-driver-devel 2.5.6-1.el10_3 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms