MONGOC_COLLECT...EXES_WITH_OPTS(3)
π MONGOC_COLLECT...EXES_WITH_OPTS(3) π
okay bestie, this is the libmongoc page for mongoc_collection_create_indexes_with_opts and its index-model besties. Itβs giving βwrap the createIndexes command, but make it cute and type-safe-ish,β and we are keeping every pointer, option, and caveat exactly where it belongs. π«Ά
πΈ SYNOPSIS πΈ
typedef struct _mongoc_index_model_t mongoc_index_model_t;
mongoc_index_model_t *
mongoc_index_model_new (const bson_t *keys, const bson_t *opts);
void mongoc_index_model_destroy (mongoc_index_model_t *model);
bool
mongoc_collection_create_indexes_with_opts (mongoc_collection_t *collection,
mongoc_index_model_t **models,
size_t n_models,
const bson_t *opts,
bson_t *reply,
bson_error_t *error);
π PARAMETERS π
collectionβ amongoc_collection_t. The collection weβre doing all this on. πmodelsβ an array ofmongoc_index_model_t *. Yep, an array of pointers, bestie.n_modelsβ the number of models. Count βem, donβt guess. π’optsβ optional options.replyβ a maybe-NULLpointer to overwritable storage for abson_tto contain the results.errorβ an optional location for abson_error_torNULL.
opts may be NULL or a BSON document with additional command options:
writeConcernβ Construct amongoc_write_concern_tand usemongoc_write_concern_append()to add the write concern toopts. See the example code formongoc_client_write_command_with_opts().sessionIdβ First, construct amongoc_client_session_twithmongoc_client_start_session(). You can begin a transaction withmongoc_client_session_start_transaction(), optionally with amongoc_transaction_opt_tthat overrides the options inherited fromcollection, and usemongoc_client_session_append()to add the session toopts. See the example code formongoc_client_session_t.collationβ Configure textual comparisons. See Setting Collation Order, and the MongoDB Manual entry on Collation. Collation requires MongoDB3.2or later, otherwise an error is returned.serverIdβ To target a specific server, include anint32"serverId"field. Obtain the id by callingmongoc_client_select_server(), thenmongoc_server_description_id()on its return value.
Additional options passed in opts are appended to the createIndexes command. See the MongoDB Manual for createIndexes for all supported options.
If no write concern is provided in opts, the collectionβs write concern is used.
π¦ mongoc_index_model_t π¦
Each mongoc_index_model_t represents an index to create. mongoc_index_model_new includes:
keysβ expected to match the form of thekeyfield in thecreateIndexescommand.optsβ optional index options appended as a sibling to thekeyfield in thecreateIndexescommand.
π DESCRIPTION π
This function wraps around the createIndexes command. Thatβs the whole vibe: itβs a wrapper, and the index models are the main characters. β¨
π ERRORS π
Errors are propagated via the error parameter. So check your error, bestie β thatβs where the drama shows up. π
π RETURNS π
Returns true if successful. Returns false and sets error if there are invalid arguments or a server or network error.
SEE ALSO: Manage Collection Indexes.
π AUTHOR π
MongoDB, Inc
π§ COPYRIGHT π§
2009-present, MongoDB, Inc.
π source/version: libmongoc 2.5.6 Β· date: Oct 09, 202 β that footer is literally cut off at 202 in the source text I got, so Iβm not inventing digits. Stay slay, bestie. π
π¦ where this page comes from
- epel 10: mongo-c-driver-devel 2.5.6-1.el10_3 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms