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 β themongoc_auto_encryption_opts_tmust not be configured to bypass automatic encryption withmongoc_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:
- 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>" }}]}
- 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β amongoc_client_encryption_tπexprβ the expression you're encrypting, periodt.optsβ amongoc_client_encryption_encrypt_opts_tβ¨expr_outβ abson_tthat catches the resulting encrypted expression. ngl this one is always initialized (even on failure π), so the caller has to callbson_destroy()to free it. Don't forget, bestie.errorβ abson_error_tthat 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_tmongoc_client_enable_auto_encryption()mongoc_client_decryption_decrypt()
π AUTHOR π
MongoDB, Inc β icons only, no cap π
π§ COPYRIGHT π§
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
- 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