MONGOC_CLIENT_...MAND_WITH_OPTS(3)
okay so this is the libmongoc page for mongoc_client_read_write_command_with_opts β manual name: libmongoc, and yes bestie, itβs giving βcommands that both read and writeβ energy π
β¨
β¨ SYNOPSIS β¨
bool
mongoc_client_read_write_command_with_opts (
mongoc_client_t *client,
const char *db_name,
const bson_t *command,
const mongoc_read_prefs_t *read_prefs /* UNUSED */,
const bson_t *opts,
bson_t *reply,
bson_error_t *error);
Execute a command on the server, applying logic for commands that both read and write, and taking the MongoDB server version into account. To send a raw command to the server without any of this logic, use mongoc_client_command_simple().
Use this function for commands that both read and write, such as "mapReduce" with an output collection. iykyk π«Ά
Read and write concern and collation can be overridden by various sources. In a transaction, read concern and write concern are prohibited in opts. The highest-priority sources for these options are listed first in the priority list below. Read preferences are not applied. The write concern is omitted for MongoDB before 3.4.
Priority sitch, highest first:
- Read concern:
opts, thenTransaction, thenclient. - Write concern:
opts, thenTransaction, thenclient. - Collation:
optsonly. thatβs the whole vibe check π
See the example for transactions and for the "distinct" command with opts.
reply is always initialized, and must be freed with bson_destroy().
π¨ lore drop, bestie: the mongoc_read_prefs_t parameter was included by mistake when this function was introduced in libmongoc 1.5. A command that writes must not obey a read preference. periodt.
π PARAMETERS π
clientβ Amongoc_client_t.db_nameβ The name of the database to run the command on.commandβ Abson_tcontaining the command specification.read_prefsβ Ignored.optsβ Abson_tcontaining additional options.replyβ A maybe-NULLpointer to overwritable storage for abson_tto contain the results.errorβ An optional location for abson_error_torNULL.
opts may be NULL or a BSON document with additional command options:
readConcernβ Construct amongoc_read_concern_tand usemongoc_read_concern_append()to add the read concern toopts. See the example code formongoc_client_read_command_with_opts(). Read concern requires MongoDB 3.2 or later, otherwise an error is returned.writeConcernβ Construct amongoc_write_concern_tand usemongoc_write_concern_append()to add the write concern toopts. See the example code formongoc_client_write_command_with_opts().sessionIdβ First, construct amongoc_client_session_twithmongoc_client_start_session(). You can begin a transaction withmongoc_client_session_start_transaction(), optionally with amongoc_transaction_opt_tthat overrides the options inherited fromclient, and usemongoc_client_session_append()to add the session toopts. See the example code formongoc_client_session_t.collationβ Configure textual comparisons. See Setting Collation Order, and the MongoDB Manual entry on Collation. Collation requires MongoDB 3.2 or later, otherwise an error is returned.serverIdβ To target a specific server, include an int32"serverId"field. Obtain the id by callingmongoc_client_select_server(), thenmongoc_server_description_id()on its return value.
Consult the MongoDB Manual entry on Database Commands for each command's arguments.
π«Ά ERRORS π«Ά
Errors are propagated via the error parameter.
π RETURNS π
Returns true if successful. Returns false and sets error if there are invalid arguments or a server or network error.
A write concern timeout or write concern error is considered a failure. no cap π
π EXAMPLE π
See the example code for mongoc_client_read_command_with_opts().
π AUTHOR π
MongoDB, Inc
π COPYRIGHT π
2009-present, MongoDB, Inc.
okay thatβs the whole page, bestie π«Άπ β this libmongoc page is version 2.5.6, dated Oct 09, 202 (the date really does cut off there in the source, bestie π). stay iconic, and may all your bson_destroy() calls be timely β¨π
π¦ 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