MONGOC_DATABASE_SET_READ_PREFS(3)
π MONGOC_DATABASE_SET_READ_PREFS(3) π
okay so bestie, welcome to libmongoc β yes that's the C driver for MongoDB and yes we're about to make your database read from exactly where you tell it to. no cap, this one's actually simple and it slays π«Ά
β¨ SYNOPSIS β¨
void
mongoc_database_set_read_prefs (mongoc_database_t *database,
const mongoc_read_prefs_t *read_prefs);
πΈ what it even does πΈ
This function sets the default read preferences to use on operations performed with database. and like β the important part β collections created with mongoc_database_get_collection() after this call will inherit these read preferences. so you're basically setting the vibe for everything that comes next, iykyk π«
The global default is MONGOC_READ_PRIMARY: if the client is connected to a replica set it reads from the primary, otherwise it reads from the current MongoDB server. that's the out-of-the-box behavior, no notes, it just works π
Please see the MongoDB website for a description of Read Preferences. (fr fr, go read it, it's giving essential context π)
π¦ PARAMETERS π¦
- database: A
mongoc_database_t. the database we're setting the vibe for π - read_prefs: A
mongoc_read_prefs_t. the read preferences themselves, freshly handed over π
π§ AUTHOR π§
MongoDB, Inc β iconic, legendary, no further questions π
β COPYRIGHT β
2009-present, MongoDB, Inc. β protect it, respect it, it's theirs π«Ά
lowkey a public service announcement: this just sets the default on database β it doesn't retroactively change collections you already grabbed. timing matters, bestie β°
and that's the whole page, bestie β you ate π signing off from libmongoc version 2.5.6, dated Oct 09, 2026 β see you in the next manpage, 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