@@ -3846,8 +3846,7 @@ This section lists the values to use for `TextOpts` for each query type.
3846
3846
}
3847
3847
` ` `
3848
3848
3849
- Use ` clientEncryption ` to encrypt the string " foobarbaz" . Ensure the type matches that of the encrypted field .
3850
- For example , if the encrypted field is ` encryptedDoubleNoPrecision ` encrypt the value 6.0 .
3849
+ Use ` clientEncryption ` to encrypt the string " foobarbaz" .
3851
3850
3852
3851
Encrypt using the following ` EncryptOpts ` :
3853
3852
@@ -3871,3 +3870,58 @@ Use `encryptedClient` to insert the following document into `db.explicit_encrypt
3871
3870
{ "_id": 0, "encryptedText": <encrypted "foobarbaz"> }
3872
3871
` ` `
3873
3872
3873
+ #### Case 1 : can find a document by prefix
3874
+
3875
+ Use ` clientEncryption.encryptExpression() ` to encrypt this query :
3876
+ ` ` ` javascript
3877
+ { "$expr": { "$encStrStartsWith": {"input": "encryptedText", "prefix": "foo"}, } }
3878
+ ` ` `
3879
+
3880
+ Store the result in ` findPayload ` .
3881
+ Use ` encryptedClient ` to run a " find" operation on the ` db.explicit_encryption ` collection with the filter ` findPayload ` .
3882
+
3883
+ Assert the following document is returned :
3884
+
3885
+ ` ` ` javascript
3886
+ { "_id": 0, "encryptedText": "foobarbaz" }
3887
+ ` ` `
3888
+
3889
+ #### Case 2 : can find a document by suffix
3890
+
3891
+ Use ` clientEncryption.encryptExpression() ` to encrypt this query :
3892
+ ` ` ` javascript
3893
+ { "$expr": { "$encStrEndsWith": {"input": "encryptedText", "suffix": "baz"}, } }
3894
+ ` ` `
3895
+
3896
+ Store the result in ` findPayload ` .
3897
+ Use ` encryptedClient ` to run a " find" operation on the ` db.explicit_encryption ` collection with the filter ` findPayload ` .
3898
+
3899
+ Assert the following document is returned :
3900
+
3901
+ ` ` ` javascript
3902
+ { "_id": 0, "encryptedText": "foobarbaz" }
3903
+ ` ` `
3904
+
3905
+ #### Case 3 : assert no document found by prefix
3906
+
3907
+ Use ` clientEncryption.encryptExpression() ` to encrypt this query :
3908
+ ` ` ` javascript
3909
+ { "$expr": { "$encStrStartsWith": {"input": "encryptedText", "prefix": "baz"}, } }
3910
+ ` ` `
3911
+
3912
+ Store the result in ` findPayload ` .
3913
+ Use ` encryptedClient ` to run a " find" operation on the ` db.explicit_encryption ` collection with the filter ` findPayload ` .
3914
+
3915
+ Assert that no documents are returned .
3916
+
3917
+ #### Case 4 : assert no document found by suffix
3918
+
3919
+ Use ` clientEncryption.encryptExpression() ` to encrypt this query :
3920
+ ` ` ` javascript
3921
+ { "$expr": { "$encStrEndsWith": {"input": "encryptedText", "suffix": "baz"}, } }
3922
+ ` ` `
3923
+
3924
+ Store the result in ` findPayload ` .
3925
+ Use ` encryptedClient ` to run a " find" operation on the ` db.explicit_encryption ` collection with the filter ` findPayload ` .
3926
+
3927
+ Assert that no documents are returned .
0 commit comments