MONGOC_DATABA...ATE_COLLECTION(3)
β¨ mongoc_database_create_collection(3) β¨
okay so bestie, welcome to libmongoc β yes, the manual is literally called that, and yes, this page is your whole guide to making a brand-new collection appear out of thin air. it's giving creation energy. π¦
πΈ SYNOPSIS πΈ
mongoc_collection_t *
mongoc_database_create_collection (mongoc_database_t *database,
const char *name,
const bson_t *opts,
bson_error_t *error);
like, that's the whole vibe. four args, one gorgeous little collection at the end. π
π PARAMETERS π
database: Amongoc_database_t. the database you're spawning this baby inside, obviously.name: The name of the new collection. pick something cute, you're stuck with it.opts: An optionalbson_tfor opts to thecreatecommand. optional optional, so you can pass nothing and still slay.error: A location for abson_error_torNULL. if you don't care about the tea when things go wrong, just passNULLand move on. π
π¦ DESCRIPTION π¦
so this function literally creates a mongoc_collection_t from the given mongoc_database_t. iconic behavior, no notes. π
if no write concern is provided in opts, the database's write concern is used. so it's not just doing whatever β it inherits the family's settings, main character energy by association. β¨
the encryptedFields document in opts may be used to create a collection used for Queryable Encryption. yes that's a real thing, yes it's a whole mood, yes the capital letters are load-bearing. π₯
for a list of all options, see the MongoDB Manual entry on the create command. don't come for me, the manual is literally right there. iykyk. π
π ERRORS π
Errors are propagated via the error parameter. so if something goes wrong, it does not just silently ghost you β it tells error, and error tells you. π«Ά
β RETURNS β
this function returns a newly allocated mongoc_collection_t upon success, NULL upon failure and error is set. periodt. if you get NULL, go check error immediately, don't just sit there like π.
also friendly reminder that "newly allocated" means you own it β free it when you're done, bestie, or it's a leak. π
π AUTHOR π
MongoDB, Inc
π COPYRIGHT π
2009-present, MongoDB, Inc.
okay that's the whole page, you ate that. π
cute little sign-off: this gorgeous piece of documentation comes from libmongoc, version 2.5.6, dated Oct 09, 2026 β so go forth, create collections, and free your memory. 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