1MONGOC_COLLECTION_CREATE_INDEXES_WMIOTlNHiG_bOOmCPo_TnCSgO(oL3cL)ECTION_CREATE_INDEXES_WITH_OPTS(3)
2
3
4
6 mongoc_collection_create_indexes_with_opts - mongoc_collection_cre‐
7 ate_indexes_with_opts()
8
10 typedef struct _mongoc_index_model_t mongoc_index_model_t;
11
12 mongoc_index_model_t *
13 mongoc_index_model_new (const bson_t *keys, const bson_t *opts);
14
15 void mongoc_index_model_destroy (mongoc_index_model_t *model);
16
17 bool
18 mongoc_collection_create_indexes_with_opts (mongoc_collection_t *collection,
19 mongoc_index_model_t **models,
20 size_t n_models,
21 const bson_t *opts,
22 bson_t *reply,
23 bson_error_t *error);
24
26 • collection: A mongoc_collection_t.
27
28 • models: An array of mongoc_index_model_t *.
29
30 • n_models: The number of models.
31
32 • opts: Optional options.
33
34 • reply: An optional location for the server reply to the createIndexes
35 command.
36
37 • error: An optional location for a bson_error_t or NULL.
38
39 opts may be NULL or a BSON document with additional command options:
40
41 • writeConcern: Construct a mongoc_write_concern_t and use
42 mongoc_write_concern_append() to add the write concern to opts. See
43 the example code for mongoc_client_write_command_with_opts().
44
45 • sessionId: First, construct a mongoc_client_session_t with
46 mongoc_client_start_session(). You can begin a transaction with
47 mongoc_client_session_start_transaction(), optionally with a
48 mongoc_transaction_opt_t that overrides the options inherited from
49 collection, and use mongoc_client_session_append() to add the session
50 to opts. See the example code for mongoc_client_session_t.
51
52 • collation: Configure textual comparisons. See Setting Collation Or‐
53 der, and the MongoDB Manual entry on Collation. Collation requires
54 MongoDB 3.2 or later, otherwise an error is returned.
55
56 • serverId: To target a specific server, include an int32 "serverId"
57 field. Obtain the id by calling mongoc_client_select_server(), then
58 mongoc_server_description_id() on its return value.
59
60 Additional options passed in opts are appended to the createIndexes
61 command. See the MongoDB Manual for createIndexes for all supported op‐
62 tions.
63
64 If no write concern is provided in opts, the collection's write concern
65 is used.
66
67 mongoc_index_model_t
68 Each mongoc_index_model_t represents an index to create. mongoc_in‐
69 dex_model_new includes:
70
71 • keys Expected to match the form of the key field in the createIndexes
72 command.
73
74 • opts Optional index options appended as a sibling to the key field in
75 the createIndexes command.
76
78 This function wraps around the createIndexes command.
79
81 Errors are propagated via the error parameter.
82
84 Returns true if successful. Returns false and sets error if there are
85 invalid arguments or a server or network error.
86
87 SEE ALSO:
88 Manage Collection Indexes.
89
90
92 MongoDB, Inc
93
95 2017-present, MongoDB, Inc
96
97
98
99
1001.24.3 AMuOgNG1O7C,_C2O0L2L3ECTION_CREATE_INDEXES_WITH_OPTS(3)