File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -242,6 +242,12 @@ declare module "mongoose" {
242
242
243
243
/** Defines or retrieves a model. */
244
244
model < T extends Document > ( name : string , schema ?: Schema , collection ?: string ) : Model < T > ;
245
+ model < T extends Document , U extends Model < T > > (
246
+ name : string ,
247
+ schema ?: Schema ,
248
+ collection ?: string ,
249
+ skipInit ?: boolean
250
+ ) : U ;
245
251
246
252
/** Returns an array of model names created on this connection. */
247
253
modelNames ( ) : Array < string > ;
Original file line number Diff line number Diff line change @@ -23,3 +23,17 @@ const ExpiresSchema = new Schema({
23
23
} ) ;
24
24
25
25
const aggregated : Promise < Document > = Test . aggregate ( [ ] ) . then ( res => res [ 0 ] ) ;
26
+
27
+ interface IProject extends Document {
28
+ name : String ;
29
+ }
30
+
31
+ interface ProjectModel extends Model < IProject > {
32
+ myStatic ( ) : number ;
33
+ }
34
+
35
+ const projectSchema : Schema = new Schema ( { name : String } ) ;
36
+ projectSchema . statics . myStatic = ( ) => 42 ;
37
+
38
+ const Project = connection . model < IProject , ProjectModel > ( 'Project' , projectSchema ) ;
39
+ Project . myStatic ( ) ;
You can’t perform that action at this time.
0 commit comments