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 β€” a mongoc_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 a bson_error_t, or NULL if 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 a mongoc_write_concern_t and use mongoc_write_concern_append() to add the write concern into opts. there's example code over on mongoc_client_write_command_with_opts() if you want the blueprint 🫢
  • sessionId β€” first, construct a mongoc_client_session_t with mongoc_client_start_session(). you can kick off a transaction with mongoc_client_session_start_transaction(), optionally with a mongoc_transaction_opt_t that overrides the options inherited from collection, then use mongoc_client_session_append() to add the session to opts. example code lives at mongoc_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 calling mongoc_client_select_server(), then mongoc_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

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