1MONGOC_CLIENT_COMMAND_WITH_OPTS(M3o)ngoDB C DrivMeOrNGOC_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            ├─────────────────┼──────────────┼───────────────┼───────────┤
34client           │              │               │           │
35            └─────────────────┴──────────────┴───────────────┴───────────┘
36
37       In a transaction, read concern and write concern are prohibited in opts
38       and the read preference must be primary or NULL.  See the  example  for
39       transactions and for the "distinct" command with opts.
40
41       reply is always initialized, and must be freed with bson_destroy().
42

PARAMETERS

44       · client: A mongoc_client_t.
45
46       · db_name: The name of the database to run the command on.
47
48       · command: A bson_t containing the command specification.
49
50       · read_prefs: An optional mongoc_read_prefs_t.
51
52       · opts: A bson_t containing additional options.
53
54       · reply: A location for the resulting document.
55
56       · error: 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
60       · readConcern:   Construct   a   mongoc_read_concern_t   and  use  mon‐
61         goc_read_concern_append to add the read  concern  to  opts.  See  the
62         example  code  for mongoc_client_read_command_with_opts. Read concern
63         requires MongoDB 3.2 or later, otherwise an error is returned.
64
65       · writeConcern:  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
69       · sessionId:  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
76       · collation:  Configure  textual  comparisons.  See  Setting  Collation
77         Order, and the MongoDB Manual entry on Collation. Collation  requires
78         MongoDB 3.2 or later, otherwise an error is returned.
79
80       · serverId:  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.14.0                           Feb 22, 2019MONGOC_CLIENT_COMMAND_WITH_OPTS(3)
Impressum