MONGOC_COLLECT...NAME_WITH_OPTS(3)
π
MONGOC_COLLECT...NAME_WITH_OPTS(3) β a libmongoc moment π
okay so bestie, welcome to the libmongoc page for MONGOC_COLLECT...NAME_WITH_OPTS(3) β yes the header is giving truncated main-character energy, but the function in question is mongoc_collection_rename_with_opts and sheβs iconic. letβs get into it π
β¨ SYNOPSIS β¨
bool
mongoc_collection_rename_with_opts (mongoc_collection_t *collection,
const char *new_db,
const char *new_name,
bool drop_target_before_rename,
const bson_t *opts,
bson_error_t *error);
πΈ PARAMETERS πΈ
collectionβ amongoc_collection_t. your main-character collection, fr.new_dbβ the name of the new database.new_nameβ the new name for the collection.drop_target_before_renameβ if an existing collection matches the new name, drop it before the rename. lowkey destructive, so read that twice π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.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.
π¦ DESCRIPTION π¦
this function is a helper to rename an existing collection on a MongoDB server. the name of the collection will also be updated internally so it is safe to continue using this collection after the rename. additional operations will occur on renamed collection.
if no write concern is provided in opts, the collectionβs write concern is used.
π ERRORS π
errors are propagated via the error parameter.
π RETURNS π
returns true if successful. returns false and sets error if there are invalid arguments or a server or network error.
π AUTHOR π
MongoDB, Inc
π§ COPYRIGHT π§
2009-present, MongoDB, Inc.
signing off with libmongoc version 2.5.6, dated Oct 09, 202 (the footer got clipped and Iβm not out here inventing digits, bestie π) β 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