MONGOC_CURSOR_...EPLY_WITH_OPTS(3)
π MONGOC_CURSOR_...EPLY_WITH_OPTS(3) β aka the libmongoc girlie who got her name cut off mid-glow-up
okay so first things first, bestie: the title of this page is literally truncated in the actual manpage β it's giving "my name got clipped in the group chat preview" π. It's the libmongoc section 3 page for mongoc_cursor_new_from_command_reply_with_opts, and yes, the header really does read MONGOC_CURSOR_...EPLY_WITH_OPTS(3) on both the top and bottom lines. We move.
β¨ SYNOPSIS β¨
mongoc_cursor_t *
mongoc_cursor_new_from_command_reply_with_opts (mongoc_client_t *client,
bson_t *reply,
const bson_t *opts);
π«Ά PARAMETERS π«Ά
clientβ amongoc_client_t. your connection bestie.replyβ the reply to a command that returns a cursor document β think"aggregate","find", or"listCollections".
β οΈ lowkey important: thereplyis destroyed bymongoc_cursor_new_from_command_reply_with_optsand must not be accessed afterward. like, it's gone, don't text it, don't look at it, it's over π
optsβ abson_t.
opts may be NULL or a BSON document with additional options, which have the same meaning for this function as for mongoc_collection_find_with_opts():
awaitDatabatchSizelimitmaxAwaitTimeMSserverIdsessionIdskiptailable
πΈ DESCRIPTION πΈ
So some MongoDB commands return a "cursor" document, right? iconic behavior. For example, given an "aggregate" command:
{ "aggregate" : "collection", "pipeline" : [], "cursor" : {}}
the server replies:
{
"cursor" : {
"id" : 1234,
"ns" : "db.collection",
"firstBatch" : [ ]
},
"ok" : 1
}
mongoc_cursor_new_from_command_reply_with_opts is a low-level function that initializes a mongoc_cursor_t from such a reply. no cap, that's the whole gig.
Now the serverId tea β: when you're synthesizing a completed cursor response that has no more batches (i.e. with cursor id 0), serverId may be 0. But if the cursor response is not completed (i.e. with a non-zero cursor id), pass the serverId of the server that was used to create the cursor. don't fumble that.
π¨ Use this function only for building a language driver that wraps the C Driver. If you're writing applications in C, higher-level functions such as mongoc_collection_aggregate() are way more appropriate, and they ensure compatibility with a range of MongoDB versions. she's a specialist tool, not a daily driver, periodt.
π RETURNS π
A mongoc_cursor_t. On failure, the cursor's error is set. Check for failure with mongoc_cursor_error(). simple as that, bestie.
π AUTHOR π
MongoDB, Inc
π¦ COPYRIGHT π¦
2009-present, MongoDB, Inc.
and that's the whole page! mwah π
okay so the sign-off: this little masterpiece is from libmongoc version 2.5.6, dated Oct 09, 202 (yes the date literally got chopped off in the source, we're all just doing our best here π), and it's filed under MONGOC_CURSOR_...EPLY_WITH_OPTS(3) at the bottom too because consistency is a vibe. go forth and cursor responsibly π§ββοΈβ
π¦ 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