@@ -3834,6 +3834,36 @@ class EncryptOpts {
3834
3834
}
3835
3835
` ` `
3836
3836
3837
+ Where prefix , suffix , or substring options are required , use the following :
3838
+
3839
+ 1. Prefix
3840
+
3841
+ ` ` ` typescript
3842
+ class PrefixOpts {
3843
+ strMaxQueryLength: 10,
3844
+ strMinQueryLength: 2,
3845
+ }
3846
+ ` ` `
3847
+
3848
+ 2. Suffix
3849
+
3850
+ ` ` ` typescript
3851
+ class SuffixOpts {
3852
+ strMaxQueryLength: 10,
3853
+ strMinQueryLength: 2,
3854
+ }
3855
+ ` ` `
3856
+
3857
+ 3. Substring
3858
+
3859
+ ` ` ` typescript
3860
+ class SubstringOpts {
3861
+ strMaxLength: 10,
3862
+ strMaxQueryLength: 10,
3863
+ strMinQueryLength: 2,
3864
+ }
3865
+ ` ` `
3866
+
3837
3867
Use ` encryptedClient ` to insert the following document into ` db.prefix-suffix ` :
3838
3868
3839
3869
` ` ` javascript
@@ -3885,42 +3915,14 @@ class EncryptOpts {
3885
3915
}
3886
3916
` ` `
3887
3917
3888
- 1. Prefix
3889
-
3890
- ` ` ` typescript
3891
- class PrefixOpts {
3892
- strMaxQueryLength: 10,
3893
- strMinQueryLength: 2,
3894
- }
3895
- ` ` `
3896
-
3897
- 2. Suffix
3898
-
3899
- ` ` ` typescript
3900
- class SuffixOpts {
3901
- strMaxQueryLength: 10,
3902
- strMinQueryLength: 2,
3903
- }
3904
- ` ` `
3905
-
3906
- 3. Substring
3907
-
3908
- ` ` ` typescript
3909
- class SubstringOpts {
3910
- strMaxLength: 10,
3911
- strMaxQueryLength: 10,
3912
- strMinQueryLength: 2,
3913
- }
3914
- ` ` `
3915
-
3916
3918
#### Case 1 : can find a document by prefix
3917
3919
3918
3920
Use ` clientEncryption.encrypt() ` to encrypt the string ` "foo" ` . Store the resulting payload in ` findPayload ` .
3919
3921
3920
3922
Use ` encryptedClient ` to run a " find" operation on the ` db.prefix-suffix ` collection with the following filter :
3921
3923
3922
3924
` ` ` javascript
3923
- { " $expr" : { " $encStrStartsWith" : {" input": " $encryptedText", " prefix" : <findPayload>}, } }
3925
+ { $expr: { $encStrStartsWith: {input: ' $encryptedText', prefix: <findPayload>}, } }
3924
3926
` ` `
3925
3927
3926
3928
Assert the following document is returned :
@@ -3931,12 +3933,12 @@ Assert the following document is returned:
3931
3933
3932
3934
#### Case 2 : can find a document by suffix
3933
3935
3934
- Use ` clientEncryption.encrypt() ` to encrypt the string ` "foo " ` . Store the resulting payload in ` findPayload ` .
3936
+ Use ` clientEncryption.encrypt() ` to encrypt the string ` "baz " ` . Store the resulting payload in ` findPayload ` .
3935
3937
3936
3938
Use ` encryptedClient ` to run a " find" operation on the ` db.prefix-suffix ` collection with the following filter :
3937
3939
3938
3940
` ` ` javascript
3939
- { " $expr" : { "$encStrStartsWith" : {" input": " $encryptedText", "prefix" : <findPayload>}, } }
3941
+ { $expr: { $encStrEndsWith : {input: ' $encryptedText', suffix : <findPayload>}, } }
3940
3942
` ` `
3941
3943
3942
3944
Assert the following document is returned :
@@ -3947,12 +3949,12 @@ Assert the following document is returned:
3947
3949
3948
3950
#### Case 3 : assert no document found by prefix
3949
3951
3950
- Use ` clientEncryption.encrypt() ` to encrypt the string ` "foo " ` . Store the resulting payload in ` findPayload ` .
3952
+ Use ` clientEncryption.encrypt() ` to encrypt the string ` "baz " ` . Store the resulting payload in ` findPayload ` .
3951
3953
3952
3954
Use ` encryptedClient ` to run a " find" operation on the ` db.prefix-suffix ` collection with the following filter :
3953
3955
3954
3956
` ` ` javascript
3955
- { " $expr" : { " $encStrStartsWith" : {" input": " $encryptedText", " prefix" : <findPayload>}, } }
3957
+ { $expr: { $encStrStartsWith: {input: ' $encryptedText', prefix: <findPayload>}, } }
3956
3958
` ` `
3957
3959
3958
3960
Assert that no documents are returned .
@@ -3964,7 +3966,7 @@ Use `clientEncryption.encrypt()` to encrypt the string `"foo"`. Store the result
3964
3966
Use ` encryptedClient ` to run a " find" operation on the ` db.prefix-suffix ` collection with the following filter :
3965
3967
3966
3968
` ` ` javascript
3967
- { " $expr" : { "$encStrStartsWith" : {" input": " $encryptedText", " suffix" : <findPayload>}, } }
3969
+ { $expr: { $encStrEndsWith : {input: ' $encryptedText', suffix: <findPayload>}, } }
3968
3970
` ` `
3969
3971
3970
3972
Assert that no documents are returned .
@@ -3976,7 +3978,7 @@ Use `clientEncryption.encrypt()` to encrypt the string `"foo"`. Store the result
3976
3978
Use ` encryptedClient ` to run a " find" operation on the ` db.substring ` collection with the following filter :
3977
3979
3978
3980
` ` ` javascript
3979
- { " $expr" : { "$encStrStartsWith" : {" input": " $encryptedText", "prefix" : <findPayload>}, } }
3981
+ { $expr: { $encStrContains : {input: ' $encryptedText', substring : <findPayload>}, } }
3980
3982
` ` `
3981
3983
3982
3984
Assert the following document is returned :
@@ -3992,7 +3994,7 @@ Use `clientEncryption.encrypt()` to encrypt the string `"qux"`. Store the result
3992
3994
Use ` encryptedClient ` to run a " find" operation on the ` db.substring ` collection with the following filter :
3993
3995
3994
3996
` ` ` javascript
3995
- { " $expr" : { "$encStrStartsWith" : {" input": " $encryptedText", "prefix" : <findPayload>}, } }
3997
+ { $expr: { $encStrContains : {input: ' $encryptedText', substring : <findPayload>}, } }
3996
3998
` ` `
3997
3999
3998
4000
Assert that no documents are returned .
0 commit comments