1MONGOC_CLIENT_COMMAND_WITH_OPTS(3) libmongocMONGOC_CLIENT_COMMAND_WITH_OPTS(3)
2
3
4

NAME

6       mongoc_client_command_with_opts - mongoc_client_command_with_opts()
7

SYNOPSIS

9          bool
10          mongoc_client_command_with_opts (
11             mongoc_client_t *client,
12             const char *db_name,
13             const bson_t *command,
14             const mongoc_read_prefs_t *read_prefs,
15             const bson_t *opts,
16             bson_t *reply,
17             bson_error_t *error);
18
19       Execute  a  command  on  the server, interpreting opts according to the
20       MongoDB server version. To send a raw command to the server without any
21       of this logic, use mongoc_client_command_simple.
22
23       Read preferences, read and write concern, and collation can be overrid‐
24       den by various sources. The highest-priority sources for these  options
25       are listed first:
26
27            ┌─────────────────┬──────────────┬───────────────┬───────────┐
28            │Read Preferences │ Read Concern │ Write Concern │ Collation │
29            ├─────────────────┼──────────────┼───────────────┼───────────┤
30read_prefs       opts         opts          opts      
31            ├─────────────────┼──────────────┼───────────────┼───────────┤
32            │Transaction      │ Transaction  │ Transaction   │           │
33            └─────────────────┴──────────────┴───────────────┴───────────┘
34
35       In a transaction, read concern and write concern are prohibited in opts
36       and the read preference must be primary or NULL.  See the  example  for
37       transactions and for the "distinct" command with opts.
38
39       reply is always initialized, and must be freed with bson_destroy().
40
41       This function is not considered a retryable read operation.
42

PARAMETERS

44client: A mongoc_client_t.
45
46db_name: The name of the database to run the command on.
47
48command: A bson_t containing the command specification.
49
50read_prefs: An optional mongoc_read_prefs_t.
51
52opts: A bson_t containing additional options.
53
54reply: A location for the resulting document.
55
56error: An optional location for a bson_error_t or NULL.
57
58       opts may be NULL or a BSON document with additional command options:
59
60readConcern:   Construct   a   mongoc_read_concern_t   and  use  mon‐
61         goc_read_concern_append to add the read concern to opts. See the  ex‐
62         ample code for mongoc_client_read_command_with_opts. Read concern re‐
63         quires MongoDB 3.2 or later, otherwise an error is returned.
64
65writeConcern:  Construct  a  mongoc_write_concern_t  and   use   mon‐
66         goc_write_concern_append  to  add  the write concern to opts. See the
67         example code for mongoc_client_write_command_with_opts.
68
69sessionId:  First,  construct  a  mongoc_client_session_t  with  mon‐
70         goc_client_start_session.  You  can  begin  a  transaction  with mon‐
71         goc_client_session_start_transaction, optionally with a mongoc_trans‐
72         action_opt_t  that  overrides  the options inherited from client, and
73         use mongoc_client_session_append to add the session to opts. See  the
74         example code for mongoc_client_session_t.
75
76collation:  Configure  textual comparisons. See Setting Collation Or‐
77         der, and the MongoDB Manual entry on  Collation.  Collation  requires
78         MongoDB 3.2 or later, otherwise an error is returned.
79
80serverId:  To  target  a specific server, include an int32 "serverId"
81         field. Obtain the id  by  calling  mongoc_client_select_server,  then
82         mongoc_server_description_id on its return value.
83
84       Consult  the  MongoDB  Manual  entry on Database Commands for each com‐
85       mand's arguments.
86

ERRORS

88       Errors are propagated via the error parameter.
89

RETURNS

91       Returns true if successful. Returns false and sets error if  there  are
92       invalid arguments or a server or network error.
93
94       The  reply  is  not parsed for a write concern timeout or write concern
95       error.
96

EXAMPLE

98       See the example code for mongoc_client_read_command_with_opts.
99

AUTHOR

101       MongoDB, Inc
102
104       2017-present, MongoDB, Inc
105
106
107
108
1091.20.0                           Nov 18, 2021MONGOC_CLIENT_COMMAND_WITH_OPTS(3)
Impressum