mongoc_cursor_new_from_command_reply_with_opts

mongoc_cursor_new_from_command_reply_with_opts()

Synopsis

mongoc_cursor_t *
mongoc_cursor_new_from_command_reply_with_opts (mongoc_client_t *client,
                                                bson_t *reply,
                                                const bson_t *opts);

Parameters

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:

Description

Some MongoDB commands return a "cursor" document. 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.

Use this function only for building a language driver that wraps the C Driver. When writing applications in C, higher-level functions such as mongoc_collection_aggregate are more appropriate, and ensure compatibility with a range of MongoDB versions.

Returns

A mongoc_cursor_t. On failure, the cursor's error is set. Check for failure with mongoc_cursor_error.

Author

MongoDB, Inc

Info

Apr 09, 2021 1.17.5 libmongoc