MONGOC_COLLECT...NDEX_WITH_OPTS(3)
π MONGOC_COLLECT...NDEX_WITH_OPTS(3) π
okay bestie, so this one lives in libmongoc, and before you get attached β it's giving retired. Scroll down to the warning first, i promise it matters. π
π¨ WARNING π¨
Deprecated since version 1.8.0. See Manage Collection Indexes for alternatives. no cap, this one's been in its flop era since 1.8.0 β go look at the alternatives instead. π
β¨ SYNOPSIS β¨
bool
mongoc_collection_create_index_with_opts (mongoc_collection_t *collection,
const bson_t *keys,
const mongoc_index_opt_t *index_opts,
const bson_t *command_opts,
bson_t *reply,
bson_error_t *error);
π PARAMETERS π
collectionβ amongoc_collection_t. the main character, obviously. πkeysβ abson_t. the key spec, serving looks.index_optsβ amongoc_index_opt_t. all the ~aesthetic~ choices.replyβ a maybe-NULLpointer to overwritable storage for abson_tthat's gonna hold the results. note the maybe-NULLbestie, it's flexible like that. π¦errorβ an optional spot for abson_error_t, orNULLif you're feeling unbothered. π
command_opts may be NULL, or a BSON document with extra command options β literally only two vibes allowed here:
writeConcernβ construct amongoc_write_concern_tand usemongoc_write_concern_append()to add the write concern toopts. peek the example code formongoc_client_write_command_with_opts()if you want the tea. β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 then usemongoc_client_session_append()to add the session toopts. example code formongoc_client_session_thas the whole story. π§
πΈ DESCRIPTION πΈ
so this function will request the creation of a new index. that's the whole gig. π«
it does that by using the createIndexes command, and the server's reply gets stored in reply.
if no write concern is provided in command_opts, then the collection's write concern is what gets used. no write concern left behind. β¨
for all the options on creating indexes, go see mongoc_index_opt_t.
π ERRORS π
errors are propagated via the error parameter. that's it, that's the whole section. straightforward fr fr.
π RETURNS π
returns true if successful. returns false and sets error if there are invalid arguments, or a server error, or a network error. π
reply is always initialized, and it must be destroyed with bson_destroy(). do not skip that, bestie, that's a leak waiting to happen. π«Ά
if the server is running an obsolete version of MongoDB then reply may be empty β but it will still be initialized. empty but valid, it's giving minimalist. π
π AUTHOR π
MongoDB, Inc
β COPYRIGHT β
2009-present, MongoDB, Inc.
and that's the whole page, periodt. this little gem is from libmongoc, version 1.30.13, dated Oct 09, 202 β yes, that's the date stamp exactly as it came, i don't make the rules. πβ¨ππ¦πΈπ
π«Ά
π¦ where this page comes from
- fedora 43: mongo-c-driver-devel 1.30.13-1.fc43 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- fedora 43: mongo-c-driver-devel 1.30.13-1.fc43 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms