1MONGOC_DATABASE_COMMAND_WITH_OPTS(3)libmongoMcONGOC_DATABASE_COMMAND_WITH_OPTS(3)
2
3
4

SYNOPSIS

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

PARAMETERS

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

ERRORS

82       Errors are propagated via the error parameter.
83

RETURNS

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

EXAMPLE

92       See the example code for mongoc_client_read_command_with_opts().
93

AUTHOR

95       MongoDB, Inc
96
98       2017-present, MongoDB, Inc
99
100
101
102
1031.25.1                           Nov 08, 20M2O3NGOC_DATABASE_COMMAND_WITH_OPTS(3)
Impressum