MONGOC_CURSOR_SET_HINT(3)

πŸ’… MONGOC_CURSOR_SET_HINT(3) β€” the libmongoc one, bestie

okay so we're in the libmongoc manual, page MONGOC_CURSOR_SET_HINT(3), and before you get attached β€” this one's on its way out. 😭 Let's get into it.


🚨 WARNING 🚨

Deprecated since version 1.28.0: use mongoc_cursor_set_server_id() instead.

like... she's retired, fr fr. if you're writing new code, go flirt with mongoc_cursor_set_server_id(). this one is just here so old code doesn't break its little heart. πŸ’”


✨ SYNOPSIS ✨

bool
mongoc_cursor_set_hint (mongoc_cursor_t *cursor, uint32_t server_id);

she takes two things and gives you back a bool. simple queen. πŸ‘‘


πŸŽ€ PARAMETERS πŸŽ€

  • cursor β€” a mongoc_cursor_t. the cursor we're blessing. πŸ¦‹
  • server_id β€” an opaque id identifying the server to use. it's opaque, bestie, don't try to read its diary. πŸ™ˆ

πŸ’– DESCRIPTION πŸ’–

so basically: this tells the driver which server to use for the operation. that's the whole vibe.

BUT β€” and this is the important part β€” it only has an effect if you call it before the find operation is executed. call it after and it's giving nothing. literally nothing. πŸ’€

also, tiny lore drop: the function name still says "hint" because of backward compatibility (iykyk), but the cool kids now call this number a "server id". the name is vintage, the concept is current. ✨

Use mongoc_cursor_set_hint only for building a language driver that wraps the C Driver. if you're writing applications in C? leave the server id unset and let the driver choose a suitable server from the find operation's read preference. she knows what she's doing, trust her. 🫢


🌈 RETURNS 🌈

  • returns true on success. slay. βœ…
  • if any arguments are invalid, returns false and logs an error. so check your args, bestie, the logs are watching. πŸ‘€

πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc β€” the icons themselves. πŸ’œ


2009-present, MongoDB, Inc.


mwah πŸ’‹ that's the whole page. this was libmongoc version 1.30.13, dated Oct 09, 2026, and you read it all the way through β€” main character energy fr. go forth and set your server ids responsibly. πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from