MONGOC_COLLECT...NDEX_WITH_OPTS(3)
πΈ MONGOC_COLLECTION_DROP_INDEX_WITH_OPTS(3) πΈ
okay bestie, you know how sometimes an index on your collection just has to go? yeah. that's this. this is the libmongoc function that drops an index with extra command options, and honestly? she's giving "quietly efficient icon." π
β¨ SYNOPSIS β¨
bool
mongoc_collection_drop_index_with_opts (mongoc_collection_t *collection,
const char *index_name,
const bson_t *opts,
bson_error_t *error);
π PARAMETERS π
collectionβ amongoc_collection_t. your collection. the one with the index you're about to yeet.index_nameβ a string holding the name of the index. not the keys, not the pointer, the name. name-drop it correctly or nothing works πerrorβ an optional place to stash abson_error_t, orNULLif you're feeling fearless.
and now the star of the show: opts can be NULL, or it can be a BSON document carrying extra command options. lowkey the fun part:
writeConcernβ build amongoc_write_concern_tand usemongoc_write_concern_append()to add the write concern intoopts. there's example code over onmongoc_client_write_command_with_opts()if you want the blueprint π«ΆsessionIdβ first, construct amongoc_client_session_twithmongoc_client_start_session(). you can kick off a transaction withmongoc_client_session_start_transaction(), optionally with amongoc_transaction_opt_tthat overrides the options inherited fromcollection, then usemongoc_client_session_append()to add the session toopts. example code lives atmongoc_client_session_t. iykyk β¨collationβ this is your textual-comparison config. peep "Setting Collation Order" and the MongoDB Manual entry on Collation. heads up fr fr: collation requires MongoDB 3.2 or later β otherwise an error gets returned, no cap.serverIdβ want to target one specific server? drop an int32"serverId"field in there. get the id by callingmongoc_client_select_server(), thenmongoc_server_description_id()on whatever it hands back. slay π―
π¦ DESCRIPTION π¦
this function requests that an index on collection be dropped. that's it. that's the whole vibe. one index, gone, bye π
and if you didn't provide a write concern in opts? no stress β the collection's write concern gets used instead. she inherits. iconic behavior honestly π
π ERRORS π
errors get propagated through the error parameter. that's where they live. that's where you look.
π RETURNS π
returns true if it worked. returns false and sets error if there are invalid arguments, or if there's a server or network error. so like, check your return value, bestie, please π
β SEE ALSO β
- Manage Collection Indexes.
π AUTHOR π
MongoDB, Inc
π COPYRIGHT π
2009-present, MongoDB, Inc.
okay that's the whole page, you absolutely ate that reading session π β¨ this was libmongoc version 2.5.6, dated Oct 09, 2024 β go forth and drop indexes responsibly, mwah ππ¦
π¦ 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