MONGOC_DATABASE_COMMAND_SIMPLE(3)
π MONGOC_DATABASE_COMMAND_SIMPLE(3) π
okay bestie, welcome to the libmongoc section of the manual, this one's all about mongoc_database_command_simple and ngl it's lowkey one of the most useful little functions in the whole library. it runs a command against a database, that's the whole vibe. let's get into it π«Ά
β¨ SYNOPSIS β¨
bool
mongoc_database_command_simple (mongoc_database_t *database,
const bson_t *command,
const mongoc_read_prefs_t *read_prefs,
bson_t *reply,
bson_error_t *error);
that's the whole signature, no cap. she takes five things and gives you back a bool. slay.
π PARAMETERS π
databaseβ amongoc_database_t. your database, your main character. πcommandβ abson_tcontaining the command. the actual thing you want to run, wrapped up all nice in bson.read_prefsβ an optionalmongoc_read_prefs_t. if you don't pass one, the command uses modeMONGOC_READ_PRIMARY. so like, primary by default, iykyk.replyβ a maybe-NULLpointer to overwritable storage for abson_tto contain the results. it's where the server's answer goes to live. πerrorβ an optional location for amongoc_error_t... wait no, amongoc_error_tisn't a thing bestie, it's abson_error_torNULL. my bad. π
πΈ THE IMPORTANT DEETS πΈ
okay so here's the thing you actually need to know, and it's giving very important:
the database's read preference, read concern, and write concern are not applied to the command. like, at all. not even a little. so don't come crying to me when your fancy write concern didn't do anything, because she literally never looked at it. π
also iconic: the parameter reply is initialized even upon failure, specifically to simplify memory management. so you never have to guess whether it's safe to clean up. she's got you. π§
and one more: this function is not considered a retryable read operation. nope. no retries. don't @ me.
π ERRORS π
errors are propagated through the error parameter. that's it, that's the section. pass your bson_error_t and she'll fill it in for you. π
β RETURNS β
returns true if successful. returns false and sets error if there are invalid arguments or a server or network error. both of those vibes, false plus a filled-in error. π₯
β οΈ warning, and this one matters: this function does not check the server response for a write concern error or write concern timeout. so if that's the kind of thing you care about, this is not the function for you, and you should go find one that does. periodt.
π AUTHOR π
MongoDB, Inc β the icons themselves. π
π¦ COPYRIGHT π¦
2009-present, MongoDB, Inc. all the legal sparkle. π
okay that's the whole page bestie, go forth and run your commands responsibly π fr fr, you got this β¨
β and for the record, this was libmongoc version 2.5.6, dated Oct 09, 2026. mwah, catch you in the next manpage. π
π¦ 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