Skip to content

Commit

Permalink
src code changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aditi-khare-mongoDB committed Jan 29, 2025
1 parent a6a51bd commit 7fa6616
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions types/schemaoptions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ declare module 'mongoose' {
* @default false
*/
overwriteModels?: boolean;

encryptionType?: 'csfle' | 'queryableEncryption';
}

interface DefaultSchemaOptions {
Expand Down
26 changes: 26 additions & 0 deletions types/schematypes.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as BSON from 'bson';

declare module 'mongoose' {

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

[other: string]: any;

encrypt?: EncryptSchemaTypeOptions;
}

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

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

export interface EncryptSchemaTypeOptions {
/** The id of the dataKey to use for encryption */
keyId: BSON.UUID;

/**
* Specifies the type of queries that the field can be queried on for Queryable Encryption.
* Required when `SchemaOptions.encryptionType` is 'queryableEncryption'
*/
queries?: 'equality' | 'range';

/**
* The algorithm to use for encryption.
* Required when `SchemaOptions.encryptionType` is 'csfle'
*/
algorithm?:
| 'AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic'
| 'AEAD_AES_256_CBC_HMAC_SHA_512-Random'
| 'Indexed'
| 'Unindexed'
| 'Range';
}

class SchemaType<T = any, DocType = any> {
/** SchemaType constructor */
constructor(path: string, options?: AnyObject, instance?: string);
Expand Down

0 comments on commit 7fa6616

Please sign in to comment.