Skip to content

Commit 7fa6616

Browse files
src code changes
1 parent a6a51bd commit 7fa6616

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

types/schemaoptions.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ declare module 'mongoose' {
258258
* @default false
259259
*/
260260
overwriteModels?: boolean;
261+
262+
encryptionType?: 'csfle' | 'queryableEncryption';
261263
}
262264

263265
interface DefaultSchemaOptions {

types/schematypes.d.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import * as BSON from 'bson';
2+
13
declare module 'mongoose' {
24

35
/** The Mongoose Date [SchemaType](/docs/schematypes.html). */
@@ -207,6 +209,8 @@ declare module 'mongoose' {
207209
maxlength?: number | [number, string] | readonly [number, string];
208210

209211
[other: string]: any;
212+
213+
encrypt?: EncryptSchemaTypeOptions;
210214
}
211215

212216
interface Validator<DocType = any> {
@@ -218,6 +222,28 @@ declare module 'mongoose' {
218222

219223
type ValidatorFunction<DocType = any> = (this: DocType, value: any, validatorProperties?: Validator) => any;
220224

225+
export interface EncryptSchemaTypeOptions {
226+
/** The id of the dataKey to use for encryption */
227+
keyId: BSON.UUID;
228+
229+
/**
230+
* Specifies the type of queries that the field can be queried on for Queryable Encryption.
231+
* Required when `SchemaOptions.encryptionType` is 'queryableEncryption'
232+
*/
233+
queries?: 'equality' | 'range';
234+
235+
/**
236+
* The algorithm to use for encryption.
237+
* Required when `SchemaOptions.encryptionType` is 'csfle'
238+
*/
239+
algorithm?:
240+
| 'AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic'
241+
| 'AEAD_AES_256_CBC_HMAC_SHA_512-Random'
242+
| 'Indexed'
243+
| 'Unindexed'
244+
| 'Range';
245+
}
246+
221247
class SchemaType<T = any, DocType = any> {
222248
/** SchemaType constructor */
223249
constructor(path: string, options?: AnyObject, instance?: string);

0 commit comments

Comments
 (0)