1MONGOC_DATABASE_READ_COMMAND_WITH_OPlTiSbM(mO3oN)nGgOoCc_DATABASE_READ_COMMAND_WITH_OPTS(3)
2
3
4

NAME

6       mongoc_database_read_command_with_opts    -   mongoc_database_read_com‐
7       mand_with_opts()
8

SYNOPSIS

10          bool
11          mongoc_database_read_command_with_opts (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, 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
21       mongoc_database_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                    ├─────────────────┼──────────────┼───────────┤
38database         │              │           │
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
46       This function is considered a retryable read operation.  Upon  a  tran‐
47       sient error (a network error, errors due to replica set failover, etc.)
48       the operation is safely retried once.  If retryreads is  false  in  the
49       URI (see mongoc_uri_t) the retry behavior does not apply.
50
51       Retry  logic  occurs  regardless  of  the  underlying command. Retrying
52       mapReduce has the potential for degraded performance.  Retrying a  get‐
53       More command has the potential to miss results. For those commands, use
54       generic command helpers (like mongoc_database_command_with_opts())  in‐
55       stead.
56

PARAMETERS

58database: A mongoc_database_t.
59
60command: A bson_t containing the command specification.
61
62read_prefs: An optional mongoc_read_prefs_t.
63
64opts: A bson_t containing additional options.
65
66reply: A location for the resulting document.
67
68error: An optional location for a bson_error_t or NULL.
69
70       opts may be NULL or a BSON document with additional command options:
71
72readConcern:    Construct    a    mongoc_read_concern_t    and    use
73         mongoc_read_concern_append() to add the read concern to opts. See the
74         example code for mongoc_client_read_command_with_opts(). Read concern
75         requires MongoDB 3.2 or later, otherwise an error is returned.
76
77sessionId:   First,   construct   a   mongoc_client_session_t    with
78         mongoc_client_start_session().  You  can  begin  a  transaction  with
79         mongoc_client_session_start_transaction(),    optionally    with    a
80         mongoc_transaction_opt_t  that  overrides  the options inherited from
81         database, and use mongoc_client_session_append() to add  the  session
82         to opts. See the example code for mongoc_client_session_t.
83
84collation:  Configure  textual comparisons. See Setting Collation Or‐
85         der, and the MongoDB Manual entry on  Collation.  Collation  requires
86         MongoDB 3.2 or later, otherwise an error is returned.
87
88serverId:  To  target  a specific server, include an int32 "serverId"
89         field. Obtain the id by calling  mongoc_client_select_server(),  then
90         mongoc_server_description_id() on its return value.
91
92       Consult  the  MongoDB  Manual  entry on Database Commands for each com‐
93       mand's arguments.
94

ERRORS

96       Errors are propagated via the error parameter.
97

RETURNS

99       Returns true if successful. Returns false and sets error if  there  are
100       invalid arguments or a server or network error.
101

EXAMPLE

103       See the example code for mongoc_client_read_command_with_opts().
104

AUTHOR

106       MongoDB, Inc
107
109       2017-present, MongoDB, Inc
110
111
112
113
1141.23.1                           Oct 2M0O,NG2O0C2_2DATABASE_READ_COMMAND_WITH_OPTS(3)
Impressum