@@ -39,7 +39,7 @@ declare module 'mongoose' {
39
39
40
40
type DefaultType < T > = T extends Schema . Types . Mixed ? any : Partial < ExtractMongooseArray < T > > ;
41
41
42
- class SchemaTypeOptions < T , EnforcedDocType = any > {
42
+ class SchemaTypeOptions < T , EnforcedDocType = any , THydratedDocumentType = any > {
43
43
type ?:
44
44
T extends string ? StringSchemaDefinition :
45
45
T extends number ? NumberSchemaDefinition :
@@ -48,19 +48,19 @@ declare module 'mongoose' {
48
48
T extends Map < any , any > ? SchemaDefinition < typeof Map > :
49
49
T extends Buffer ? SchemaDefinition < typeof Buffer > :
50
50
T extends Types . ObjectId ? ObjectIdSchemaDefinition :
51
- T extends Types . ObjectId [ ] ? AnyArray < ObjectIdSchemaDefinition > | AnyArray < SchemaTypeOptions < ObjectId , EnforcedDocType > > :
52
- T extends object [ ] ? ( AnyArray < Schema < any , any , any > > | AnyArray < SchemaDefinition < Unpacked < T > > > | AnyArray < SchemaTypeOptions < Unpacked < T > , EnforcedDocType > > ) :
53
- T extends string [ ] ? AnyArray < StringSchemaDefinition > | AnyArray < SchemaTypeOptions < string , EnforcedDocType > > :
54
- T extends number [ ] ? AnyArray < NumberSchemaDefinition > | AnyArray < SchemaTypeOptions < number , EnforcedDocType > > :
55
- T extends boolean [ ] ? AnyArray < BooleanSchemaDefinition > | AnyArray < SchemaTypeOptions < boolean , EnforcedDocType > > :
56
- T extends Function [ ] ? AnyArray < Function | string > | AnyArray < SchemaTypeOptions < Unpacked < T > , EnforcedDocType > > :
57
- T | typeof SchemaType | Schema < any , any , any > | SchemaDefinition < T > | Function | AnyArray < Function > ;
51
+ T extends Types . ObjectId [ ] ? AnyArray < ObjectIdSchemaDefinition > | AnyArray < SchemaTypeOptions < ObjectId , EnforcedDocType , THydratedDocumentType > > :
52
+ T extends object [ ] ? ( AnyArray < Schema < any , any , any > > | AnyArray < SchemaDefinition < Unpacked < T > , EnforcedDocType , THydratedDocumentType > > | AnyArray < SchemaTypeOptions < Unpacked < T > , EnforcedDocType , THydratedDocumentType > > ) :
53
+ T extends string [ ] ? AnyArray < StringSchemaDefinition > | AnyArray < SchemaTypeOptions < string , EnforcedDocType , THydratedDocumentType > > :
54
+ T extends number [ ] ? AnyArray < NumberSchemaDefinition > | AnyArray < SchemaTypeOptions < number , EnforcedDocType , THydratedDocumentType > > :
55
+ T extends boolean [ ] ? AnyArray < BooleanSchemaDefinition > | AnyArray < SchemaTypeOptions < boolean , EnforcedDocType , THydratedDocumentType > > :
56
+ T extends Function [ ] ? AnyArray < Function | string > | AnyArray < SchemaTypeOptions < Unpacked < T > , EnforcedDocType , THydratedDocumentType > > :
57
+ T | typeof SchemaType | Schema < any , any , any > | SchemaDefinition < T , EnforcedDocType , THydratedDocumentType > | Function | AnyArray < Function > ;
58
58
59
59
/** Defines a virtual with the given name that gets/sets this path. */
60
60
alias ?: string | string [ ] ;
61
61
62
62
/** Function or object describing how to validate this schematype. See [validation docs](https://mongoosejs.com/docs/validation.html). */
63
- validate ?: SchemaValidator < T , EnforcedDocType > | AnyArray < SchemaValidator < T , EnforcedDocType > > ;
63
+ validate ?: SchemaValidator < T , THydratedDocumentType > | AnyArray < SchemaValidator < T , THydratedDocumentType > > ;
64
64
65
65
/** Allows overriding casting logic for this individual path. If a string, the given string overwrites Mongoose's default cast error message. */
66
66
cast ?: string |
@@ -74,13 +74,13 @@ declare module 'mongoose' {
74
74
* path cannot be set to a nullish value. If a function, Mongoose calls the
75
75
* function and only checks for nullish values if the function returns a truthy value.
76
76
*/
77
- required ?: boolean | ( ( this : EnforcedDocType ) => boolean ) | [ boolean , string ] | [ ( this : EnforcedDocType ) => boolean , string ] ;
77
+ required ?: boolean | ( ( this : THydratedDocumentType ) => boolean ) | [ boolean , string ] | [ ( this : THydratedDocumentType ) => boolean , string ] ;
78
78
79
79
/**
80
80
* The default value for this path. If a function, Mongoose executes the function
81
81
* and uses the return value as the default.
82
82
*/
83
- default ?: DefaultType < T > | ( ( this : EnforcedDocType , doc : any ) => DefaultType < T > ) | null ;
83
+ default ?: DefaultType < T > | ( ( this : THydratedDocumentType , doc : THydratedDocumentType ) => DefaultType < T > ) | null ;
84
84
85
85
/**
86
86
* The model that `populate()` should use if populating this path.
0 commit comments