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