MONGOC_CLIENT...YPT_EXPRESSION(3)

πŸ’… MONGOC_CLIENT_ENCRYPT_EXPRESSION πŸ’…

okay so bestie, we're in the libmongoc manual and today's main character is mongoc_client_encryption_encrypt_expression β€” yes that's a mouthful, just vibe with it πŸ’–


✨ SYNOPSIS ✨

bool
mongoc_client_encryption_encrypt_expression (
   mongoc_client_encryption_t *client_encryption,
   const bson_t *expr,
   mongoc_client_encryption_encrypt_opts_t *opts,
   bson_t *expr_out,
   bson_error_t *error);

New in version 1.24.0. πŸŽ€


🌸 DESCRIPTION 🌸

So this function encrypts a Match Expression or Aggregate Expression so you can query a range index. It's giving "I have a secret and I'm telling you in code." πŸ”

If you wanna query with a Range encrypted payload, you use a mongoc_client_t that's configured with mongoc_auto_encryption_opts_t β€” that's the vibe. And ooh, the mongoc_auto_encryption_opts_t may be configured to bypass query analysis with mongoc_auto_encryption_opts_set_bypass_query_analysis(). Slay.

⚠️ But listen β€” the mongoc_auto_encryption_opts_t must not be configured to bypass automatic encryption with mongoc_auto_encryption_opts_set_bypass_auto_encryption(). Like, that's a hard no, bestie. 🚫

To query with a Range payload, expr has to be one of these two forms:

  1. A Match Expression of the following form:
// $gt may also be $gte. $lt may also be $lte.
// Can include one of $gt/$gte/$lt/$lte. It is not required to include both.
{"$and": [{"<field>": {"$gt": "<value1>"}}, {"<field>": {"$lt": "<value2>" }}]}
  1. An Aggregation Expression of this form:
// $gt may also be $gte. $lt may also be $lte
// Can include one of $gt/$gte/$lt/$lte. It is not required to include both.
{"$and": [{"$gt": ["<fieldpath>", "<value1>"]}, {"$lt": ["<fieldpath>", "<value2>"]}]

πŸ¦‹ PARAMETERS πŸ¦‹

  • client_encryption β€” a mongoc_client_encryption_t πŸ‘‘
  • expr β€” the expression you're encrypting, periodt.
  • opts β€” a mongoc_client_encryption_encrypt_opts_t ✨
  • expr_out β€” a bson_t that catches the resulting encrypted expression. ngl this one is always initialized (even on failure 😭), so the caller has to call bson_destroy() to free it. Don't forget, bestie.
  • error β€” a bson_error_t that gets set on failure πŸ’€

πŸ’œ RETURNS πŸ’œ

Returns true if successful. Returns false and sets error otherwise. That's the whole vibe check 🌈

πŸŽ€ SEE ALSO πŸŽ€

  • mongoc_client_encryption_encrypt_opts_t
  • mongoc_client_enable_auto_encryption()
  • mongoc_client_decryption_decrypt()

πŸ“ AUTHOR πŸ“

MongoDB, Inc β€” icons only, no cap πŸ‘‘

2009-present, MongoDB, Inc.


and that's the whole page, bestie 🫢 this was libmongoc version 2.5.6, dated Oct 09, 2026 β€” mwah, go encrypt something iconic πŸ’…πŸ’–

πŸ“¦ where this page comes from