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

SYNOPSIS

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

PARAMETERS

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

ERRORS

85       Errors are propagated via the error parameter.
86

RETURNS

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

EXAMPLE

95       See the example code for mongoc_client_read_command_with_opts().
96

AUTHOR

98       MongoDB, Inc
99
101       2017-present, MongoDB, Inc
102
103
104
105
1061.25.1                           Nov 08, 2023MONGOC_CLIENT_COMMAND_WITH_OPTS(3)
Impressum