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

NAME

6       mongoc_database_command_with_opts - mongoc_database_command_with_opts()
7

SYNOPSIS

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

PARAMETERS

43database: A mongoc_database_t.
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  mon‐
58         goc_read_concern_append to add the read concern to opts. See the  ex‐
59         ample code for mongoc_client_read_command_with_opts. Read concern re‐
60         quires MongoDB 3.2 or later, otherwise an error is returned.
61
62writeConcern:  Construct  a  mongoc_write_concern_t  and   use   mon‐
63         goc_write_concern_append  to  add  the write concern to opts. See the
64         example code for mongoc_client_write_command_with_opts.
65
66sessionId:  First,  construct  a  mongoc_client_session_t  with  mon‐
67         goc_client_start_session.  You  can  begin  a  transaction  with mon‐
68         goc_client_session_start_transaction, optionally with a mongoc_trans‐
69         action_opt_t  that overrides the options inherited from database, and
70         use mongoc_client_session_append to add the session to opts. See  the
71         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.17.6                           Jun 03, 20M2O1NGOC_DATABASE_COMMAND_WITH_OPTS(3)
Impressum