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 β€” a mongoc_cursor_t. yeah. the cursor. the main character. πŸ‘‘
  • bson β€” a location for a bson_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: the bson you get back is only valid until the next call to mongoc_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 πŸ’œ


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