MONGOC_DATABASE_DROP_WITH_OPTS(3)

πŸ’… MONGOC_DATABASE_DROP_WITH_OPTS πŸ’…

okay bestie, so this is a page straight out of libmongoc (that's the MongoDB C driver, iykyk) and it's all about yeeting a whole database into the void. dramatic? maybe. necessary? absolutely. let's get into it 🫢


✨ SYNOPSIS ✨

bool
mongoc_database_drop_with_opts (mongoc_database_t *database,
                                const bson_t *opts,
                                bson_error_t *error);

literally just one function, three args, and a dream πŸ’–


πŸŽ€ PARAMETERS πŸŽ€

  • database β€” a mongoc_database_t, aka the database you're about to say bye-bye to πŸ‘‹
  • error β€” an optional spot to stash a bson_error_t, or NULL if you're feeling brave (no cap, if you pass NULL you get zero gossip about what went wrong)

so opts can be NULL, or it can be a BSON document stuffed with extra command options. here's the menu:

  • writeConcern β€” build a mongoc_write_concern_t and use mongoc_write_concern_append() to slide the write concern into opts. there's example code over on mongoc_client_write_command_with_opts() if you want to see it in action ✨
  • sessionId β€” first, make a mongoc_client_session_t with mongoc_client_start_session(). you can kick off a transaction with mongoc_client_session_start_transaction(), optionally passing a mongoc_transaction_opt_t that overrides the options inherited from database, then use mongoc_client_session_append() to add the session to opts. example code lives with mongoc_client_session_t πŸ’œ
  • collation β€” this one's for configuring textual comparisons. see Setting Collation Order, plus the MongoDB Manual entry on Collation. heads up though: collation requires MongoDB 3.2 or later β€” on anything older you get an error back, no mercy 😭
  • serverId β€” wanna 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 🎯

πŸ¦‹ DESCRIPTION πŸ¦‹

this function attempts to drop a database on the MongoDB server. that's it, that's the whole vibe. database? gone. ✨

if no write concern is provided in opts, the database's own write concern gets used instead β€” it's giving "inherited from the parent," honestly very main character of it πŸ‘‘

the encryptedFields document in opts may be used to drop a collection used for Queryable Encryption πŸ” (yes, you read that right, and yes, we're keeping it exactly as written)


πŸ’€ ERRORS πŸ’€

errors get propagated through the error parameter. simple as that, bestie 🫢


⭐ RETURNS ⭐

returns true if it slayed. returns false and sets error if the arguments are invalid, or if there's a server or network error. so like β€” check it, yeah? πŸ™ˆ


πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc


2009-present, MongoDB, Inc.


and that's the whole page, bestie πŸ’… this beaut came to you from libmongoc, version 2.5.6, dated Oct 09, 2026 β€” go forth and drop responsibly, mwah πŸ“πŸ§š

πŸ“¦ where this page comes from