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 β€” a mongoc_database_t. your database, your main character. πŸ’œ
  • command β€” a bson_t containing the command. the actual thing you want to run, wrapped up all nice in bson.
  • read_prefs β€” an optional mongoc_read_prefs_t. if you don't pass one, the command uses mode MONGOC_READ_PRIMARY. so like, primary by default, iykyk.
  • reply β€” a maybe-NULL pointer to overwritable storage for a bson_t to contain the results. it's where the server's answer goes to live. πŸ’Œ
  • error β€” an optional location for a mongoc_error_t... wait no, a mongoc_error_t isn't a thing bestie, it's a bson_error_t or NULL. 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. 🌈


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