@@ -141,12 +141,12 @@ declare module 'mongoose' {
141
141
> = IfAny <
142
142
DocType ,
143
143
any ,
144
- Document < unknown , TQueryHelpers , DocType > & MergeType <
145
- Require_id < DocType > ,
146
- TOverrides extends Record < string , never > ?
147
- { } :
144
+ TOverrides extends Record < string , never > ?
145
+ Document < unknown , TQueryHelpers , DocType > & Require_id < DocType > :
146
+ Document < unknown , TQueryHelpers , DocType > & MergeType <
147
+ Require_id < DocType > ,
148
148
IfAny < TOverrides , { } >
149
- >
149
+ >
150
150
> ;
151
151
export type HydratedSingleSubdocument < DocType , TOverrides = { } > = Types . Subdocument < unknown > & Require_id < DocType > & TOverrides ;
152
152
export type HydratedArraySubdocument < DocType , TOverrides = { } > = Types . ArraySubdocument < unknown > & Require_id < DocType > & TOverrides ;
@@ -212,7 +212,7 @@ declare module 'mongoose' {
212
212
213
213
export class Schema <
214
214
EnforcedDocType = any ,
215
- M = Model < EnforcedDocType , any , any , any > ,
215
+ TModelType = Model < EnforcedDocType , any , any , any > ,
216
216
TInstanceMethods = { } ,
217
217
TQueryHelpers = { } ,
218
218
TVirtuals = { } ,
@@ -311,7 +311,7 @@ declare module 'mongoose' {
311
311
pathType ( path : string ) : string ;
312
312
313
313
/** Registers a plugin for this schema. */
314
- plugin < PFunc extends PluginFunction < DocType , M , any , any , any , any > , POptions extends Parameters < PFunc > [ 1 ] = Parameters < PFunc > [ 1 ] > ( fn : PFunc , opts ?: POptions ) : this;
314
+ plugin < PFunc extends PluginFunction < DocType , TModelType , any , any , any , any > , POptions extends Parameters < PFunc > [ 1 ] = Parameters < PFunc > [ 1 ] > ( fn : PFunc , opts ?: POptions ) : this;
315
315
316
316
/** Defines a post hook for the model. */
317
317
@@ -320,7 +320,7 @@ declare module 'mongoose' {
320
320
post < T = Query < any , any > > ( method : MongooseQueryMiddleware | MongooseQueryMiddleware [ ] | RegExp , options : SchemaPostOptions & { errorHandler : true } , fn : ErrorHandlingMiddlewareWithOption < T > ) : this;
321
321
post < T = THydratedDocumentType > ( method : MongooseDocumentMiddleware | MongooseDocumentMiddleware [ ] | RegExp , options : SchemaPostOptions & { errorHandler : true } , fn : ErrorHandlingMiddlewareWithOption < T > ) : this;
322
322
post < T extends Aggregate < any > > ( method : 'aggregate' | RegExp , options : SchemaPostOptions & { errorHandler : true } , fn : ErrorHandlingMiddlewareWithOption < T , Array < any > > ) : this;
323
- post < T = M > ( method : 'insertMany' | RegExp , options : SchemaPostOptions & { errorHandler : true } , fn : ErrorHandlingMiddlewareWithOption < T > ) : this;
323
+ post < T = TModelType > ( method : 'insertMany' | RegExp , options : SchemaPostOptions & { errorHandler : true } , fn : ErrorHandlingMiddlewareWithOption < T > ) : this;
324
324
325
325
// this = never since it never happens
326
326
post < T = never > ( method : MongooseQueryOrDocumentMiddleware | MongooseQueryOrDocumentMiddleware [ ] | RegExp , options : SchemaPostOptions & { document : false , query : false } , fn : PostMiddlewareFunction < never , never > ) : this;
@@ -358,14 +358,14 @@ declare module 'mongoose' {
358
358
// method aggregate and insertMany with PostMiddlewareFunction
359
359
post < T extends Aggregate < any > > ( method : 'aggregate' | RegExp , fn : PostMiddlewareFunction < T , Array < AggregateExtract < T > > > ) : this;
360
360
post < T extends Aggregate < any > > ( method : 'aggregate' | RegExp , options : SchemaPostOptions , fn : PostMiddlewareFunction < T , Array < AggregateExtract < T > > > ) : this;
361
- post < T = M > ( method : 'insertMany' | RegExp , fn : PostMiddlewareFunction < T , T > ) : this;
362
- post < T = M > ( method : 'insertMany' | RegExp , options : SchemaPostOptions , fn : PostMiddlewareFunction < T , T > ) : this;
361
+ post < T = TModelType > ( method : 'insertMany' | RegExp , fn : PostMiddlewareFunction < T , T > ) : this;
362
+ post < T = TModelType > ( method : 'insertMany' | RegExp , options : SchemaPostOptions , fn : PostMiddlewareFunction < T , T > ) : this;
363
363
364
364
// method aggregate and insertMany with ErrorHandlingMiddlewareFunction
365
365
post < T extends Aggregate < any > > ( method : 'aggregate' | RegExp , fn : ErrorHandlingMiddlewareFunction < T , Array < any > > ) : this;
366
366
post < T extends Aggregate < any > > ( method : 'aggregate' | RegExp , options : SchemaPostOptions , fn : ErrorHandlingMiddlewareFunction < T , Array < any > > ) : this;
367
- post < T = M > ( method : 'insertMany' | RegExp , fn : ErrorHandlingMiddlewareFunction < T > ) : this;
368
- post < T = M > ( method : 'insertMany' | RegExp , options : SchemaPostOptions , fn : ErrorHandlingMiddlewareFunction < T > ) : this;
367
+ post < T = TModelType > ( method : 'insertMany' | RegExp , fn : ErrorHandlingMiddlewareFunction < T > ) : this;
368
+ post < T = TModelType > ( method : 'insertMany' | RegExp , options : SchemaPostOptions , fn : ErrorHandlingMiddlewareFunction < T > ) : this;
369
369
370
370
/** Defines a pre hook for the model. */
371
371
// this = never since it never happens
@@ -390,8 +390,8 @@ declare module 'mongoose' {
390
390
pre < T extends Aggregate < any > > ( method : 'aggregate' | RegExp , fn : PreMiddlewareFunction < T > ) : this;
391
391
pre < T extends Aggregate < any > > ( method : 'aggregate' | RegExp , options : SchemaPreOptions , fn : PreMiddlewareFunction < T > ) : this;
392
392
/* method insertMany */
393
- pre < T = M > ( method : 'insertMany' | RegExp , fn : ( this : T , next : ( err ?: CallbackError ) => void , docs : any | Array < any > ) => void | Promise < void > ) : this;
394
- pre < T = M > ( method : 'insertMany' | RegExp , options : SchemaPreOptions , fn : ( this : T , next : ( err ?: CallbackError ) => void , docs : any | Array < any > ) => void | Promise < void > ) : this;
393
+ pre < T = TModelType > ( method : 'insertMany' | RegExp , fn : ( this : T , next : ( err ?: CallbackError ) => void , docs : any | Array < any > ) => void | Promise < void > ) : this;
394
+ pre < T = TModelType > ( method : 'insertMany' | RegExp , options : SchemaPreOptions , fn : ( this : T , next : ( err ?: CallbackError ) => void , docs : any | Array < any > ) => void | Promise < void > ) : this;
395
395
396
396
/** Object of currently defined query helpers on this schema. */
397
397
query : TQueryHelpers ;
@@ -413,11 +413,12 @@ declare module 'mongoose' {
413
413
414
414
/** Adds static "class" methods to Models compiled from this schema. */
415
415
static < K extends keyof TStaticMethods > ( name : K , fn : TStaticMethods [ K ] ) : this;
416
- static ( obj : { [ F in keyof TStaticMethods ] : TStaticMethods [ F ] } & { [ name : string ] : ( this : M , ...args : any [ ] ) => any } ) : this;
417
- static ( name : string , fn : ( this : M , ...args : any [ ] ) => any ) : this;
416
+ static ( obj : { [ F in keyof TStaticMethods ] : TStaticMethods [ F ] } & { [ name : string ] : ( this : TModelType , ...args : any [ ] ) => any } ) : this;
417
+ static ( name : string , fn : ( this : TModelType , ...args : any [ ] ) => any ) : this;
418
418
419
419
/** Object of currently defined statics on this schema. */
420
- statics : { [ F in keyof TStaticMethods ] : TStaticMethods [ F ] } & { [ name : string ] : ( this : M , ...args : any [ ] ) => any } ;
420
+ statics : { [ F in keyof TStaticMethods ] : TStaticMethods [ F ] } &
421
+ { [ name : string ] : ( this : TModelType , ...args : any [ ] ) => unknown } ;
421
422
422
423
/** Creates a virtual type with the given name. */
423
424
virtual < T = HydratedDocument < DocType , TVirtuals & TInstanceMethods , TQueryHelpers > > (
0 commit comments