MONGOC_CLIENT_SELECT_SERVER(3)
π¦ SYNOPSIS π¦
okay bestie, welcome to the mongoc_client_select_server(3) page from libmongoc β this is the little function that picks a server for an operation, using the logic from the Server Selection Spec β¨
mongoc_server_description_t *
mongoc_client_select_server (mongoc_client_t *client,
bool for_writes,
const mongoc_read_prefs_t *prefs,
bson_error_t *error);
Use this function only for building a language driver that wraps the C Driver. When you're writing applications in C, higher-level functions automatically select a suitable server, so you don't gotta do it yourself π
πΈ PARAMETERS πΈ
clientβ Amongoc_client_t. the main character of this whole situation π«Άfor_writesβ Whether to choose a server suitable for writes or reads. lowkey important vibe check βprefsβ An optionalmongoc_read_prefs_t. Iffor_writesistrue,prefsmust beNULL. Otherwise, useprefsto customize server selection, or passNULLto use read preferencePRIMARY. no cap, that's the rule πerrorβ An optional location for abson_error_torNULL. put anerrorhere if you want the tea when things go sideways π
β¨ RETURNS β¨
A mongoc_server_description_t that must be freed with mongoc_server_description_destroy(). If no suitable server is found, returns NULL and error is filled out. so like, if it comes back NULL, check the error β it's giving "the server selection said no" π
π AUTHOR π
MongoDB, Inc β iconic, honestly π
π COPYRIGHT π
2009-present, MongoDB, Inc. β periodt, protect the copyright π«‘
mwah π β this page is from libmongoc version 2.5.6, dated Oct 09, 2026. bye bestie, go select a server slayfully π§π
π¦ 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