MONGOC_COLLECTION_RENAME(3)

πŸ’… MONGOC_COLLECTION_RENAME(3) β€” the libmongoc glow-up your collection deserves

okay bestie, so you wanna rename a collection? say less. this is a libmongoc thing, and it's genuinely one of the simpler little functions in the whole library β€” a real "just vibes" moment. ✨

πŸ¦‹ SYNOPSIS

bool
mongoc_collection_rename (mongoc_collection_t *collection,
                          const char *new_db,
                          const char *new_name,
                          bool drop_target_before_rename,
                          bson_error_t *error);

that's it. that's the whole signature. it returns a bool, and honestly the bool is the main character here β€” you gotta check it. πŸ”₯


πŸŽ€ PARAMETERS

  • collection β€” A mongoc_collection_t. this is your collection, your fave, the one getting the makeover. πŸ’–
  • new_db β€” The name of the new database. yes, you can move it to a whole different database. it's giving relocation era. πŸ¦‹
  • new_name β€” The new name for the collection. pick something cute, or pick something boring, no judgement, it's your life.
  • drop_target_before_rename β€” If an existing collection matches the new name, drop it before the rename. ⚠️ heads up β€” this one is the "yikes" flag, because if something's already sitting there with that name, it gets dropped. like, gone. so be sure before you set this to true, fr fr.
  • error β€” An optional location for a bson_error_t or NULL. you can pass NULL if you're feeling fearless (or just want to ignore errors, which… bestie, no, but do you). πŸ™ˆ

🌸 DESCRIPTION

okay so here's the tea: for more information, see mongoc_collection_rename_with_opts(). this function is a thin wrapper, passing NULL in as bson_t parameter. 🫢

so like, it's literally just mongoc_collection_rename_with_opts() wearing a slightly simpler outfit. if you want the options, go to that one. if you want the no-frills version, you're already here, and you're slaying. πŸ’…

ngl, "thin wrapper" is doing a lot of work in that sentence, but that's genuinely all it is β€” no hidden behaviour, no extra steps, just the NULL bson_t and off you go. ✨

πŸ‘‘ AUTHOR

MongoDB, Inc

2009-present, MongoDB, Inc.


and that's the page, bestie! 🌈 this lil' slice of libmongoc is version 2.5.6, dated Oct 09, 2026, brought to you by the fine people at MongoDB, Inc β€” go rename something iconic, and remember to check that bool. πŸ˜­πŸ’–

πŸ“¦ where this page comes from