1MONGOC_COLLECTION_READ_COMMAND_WMIoTnHg_oMODOPBNTGSCO(C3D_)rCiOvLeLrECTION_READ_COMMAND_WITH_OPTS(3)
2
3
4

NAME

6       mongoc_collection_read_command_with_opts  - mongoc_collection_read_com‐
7       mand_with_opts()
8

SYNOPSIS

10          bool
11          mongoc_collection_read_command_with_opts (mongoc_collection_t *collection,
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, applying logic  that  is  specific  to
19       commands that read, and taking the MongoDB server version into account.
20       To send a raw command to the server without any of this logic, use mon‐
21       goc_collection_command_simple.
22
23       Use this function for commands that read such as "count" or "distinct".
24
25       Read preferences, read concern, and collation can be overridden by var‐
26       ious sources. In a transaction, read concern and write concern are pro‐
27       hibited  in  opts  and the read preference must be primary or NULL. The
28       highest-priority sources for these options are listed first in the fol‐
29       lowing table. No write concern is applied.
30
31                    ┌─────────────────┬──────────────┬───────────┐
32                    │Read Preferences │ Read Concern │ Collation │
33                    ├─────────────────┼──────────────┼───────────┤
34read_prefs       opts         opts      
35                    ├─────────────────┼──────────────┼───────────┤
36                    │Transaction      │ Transaction  │           │
37                    ├─────────────────┼──────────────┼───────────┤
38collection       │              │           │
39                    └─────────────────┴──────────────┴───────────┘
40
41       See  the  example  for transactions and for the "distinct" command with
42       opts.
43
44       reply is always initialized, and must be freed with bson_destroy().
45

PARAMETERS

47       · collection: A mongoc_collection_t.
48
49       · command: A bson_t containing the command specification.
50
51       · read_prefs: An optional mongoc_read_prefs_t.
52
53       · opts: A bson_t containing additional options.
54
55       · reply: A location for the resulting document.
56
57       · error: An optional location for a bson_error_t or NULL.
58
59       opts may be NULL or a BSON document with additional command options:
60
61       · readConcern:  Construct  a   mongoc_read_concern_t   and   use   mon‐
62         goc_read_concern_append  to  add  the  read  concern to opts. See the
63         example code for mongoc_client_read_command_with_opts.  Read  concern
64         requires MongoDB 3.2 or later, otherwise an error is returned.
65
66       · sessionId:  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  collection,
70         and  use mongoc_client_session_append to add the session to opts. See
71         the example code for mongoc_client_session_t.
72
73       · collation:  Configure  textual  comparisons.  See  Setting  Collation
74         Order,  and the MongoDB Manual entry on Collation. Collation requires
75         MongoDB 3.2 or later, otherwise an error is returned.
76
77       · serverId: 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

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.14.0                           FebMO2N2G,OC2_0C1O9LLECTION_READ_COMMAND_WITH_OPTS(3)
Impressum