MONGOC_DATABAS...MAND_WITH_OPTS(3)
π mongoc_database_read_command_with_opts(3) β libmongoc π
okay so bestie, welcome to the libmongoc page for mongoc_database_read_command_with_opts(3). Itβs giving βread command, but make it smart about server versions and read logicβ β¨
β¨ SYNOPSIS β¨
bool
mongoc_database_read_command_with_opts (mongoc_database_t *database,
const bson_t *command,
const mongoc_read_prefs_t *read_prefs,
const bson_t *opts,
bson_t *reply,
bson_error_t *error);
πΈ DESCRIPTION πΈ
Execute a command on the server, applying logic that is specific to commands that read, and taking the MongoDB server version into account. To send a raw command to the server without any of this logic, use mongoc_database_command_simple().
Use this function for commands that read such as "count" or "distinct".
Read preferences, read concern, and collation can be overridden by various sources. In a transaction, read concern and write concern are prohibited in opts and the read preference must be primary or NULL. The highest-priority sources for these options are listed first, bestie:
- Read Preferences β highest priority first:
read_prefs, then Transaction, thendatabase. - Read Concern β highest priority first:
opts, then Transaction. - Collation β highest priority first:
opts.
No write concern is applied. periodt.
See the example for transactions and for the "distinct" command with opts.
reply is always initialized, and must be freed with bson_destroy().
This function is considered a retryable read operation. Upon a transient error (a network error, errors due to replica set failover, etc.) the operation is safely retried once. If retryreads is false in the URI (see mongoc_uri_t) the retry behavior does not apply.
Retry logic occurs regardless of the underlying command. Retrying mapReduce has the potential for degraded performance. Retrying a getMore command has the potential to miss results. For those commands, use generic command helpers (like mongoc_database_command_with_opts()) instead.
π PARAMETERS π
databaseβ Amongoc_database_t.commandβ Abson_tcontaining the command specification.read_prefsβ An optionalmongoc_read_prefs_t.optsβ Abson_tcontaining additional options.replyβ A maybe-NULL pointer 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.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 fromdatabase, 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.
π EXAMPLE π
See the example code for mongoc_client_read_command_with_opts().
π AUTHOR π
MongoDB, Inc
π COPYRIGHT π
2009-present, MongoDB, Inc.
catch you later, bestie β this libmongoc page is version 2.5.6, dated Oct 09, 202 ππ«Ά
π¦ 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