@@ -57,7 +57,7 @@ export declare abstract class Model<T> extends Hooks {
57
57
* @param schema The name of the schema
58
58
* @param options
59
59
*/
60
- static schema < T extends Model < T > > ( schema : string , options ?: SchemaOptions ) : Model < T > ;
60
+ static schema < T extends Model < T > > ( this : ( new ( ) => T ) , schema : string , options ?: SchemaOptions ) : Model < T > ;
61
61
62
62
/**
63
63
* Get the tablename of the model, taking schema into account. The method will return The name as a string
@@ -130,7 +130,7 @@ export declare abstract class Model<T> extends Hooks {
130
130
* @return Model A reference to the model, with the scope(s) applied. Calling scope again on the returned
131
131
* model will clear the previous scope.
132
132
*/
133
- static scope ( options ?: string | string [ ] | ScopeOptions | WhereOptions < any > ) : typeof Model ;
133
+ static scope < T extends Model < T > > ( this : ( new ( ) => T ) , options ?: string | string [ ] | ScopeOptions | WhereOptions < any > ) : typeof T ;
134
134
135
135
/**
136
136
* Search for multiple instances.
@@ -194,25 +194,25 @@ export declare abstract class Model<T> extends Hooks {
194
194
*
195
195
* @see {Sequelize#query}
196
196
*/
197
- static findAll < T extends Model < T > > ( options ?: IFindOptions < T > ) : Promise < T [ ] > ;
197
+ static findAll < T extends Model < T > > ( this : ( new ( ) => T ) , options ?: IFindOptions < T > ) : Promise < T [ ] > ;
198
198
199
- static all < T extends Model < T > > ( options ?: IFindOptions < T > ) : Promise < T [ ] > ;
199
+ static all < T extends Model < T > > ( this : ( new ( ) => T ) , options ?: IFindOptions < T > ) : Promise < T [ ] > ;
200
200
201
201
/**
202
202
* Search for a single instance by its primary key. This applies LIMIT 1, so the listener will
203
203
* always be called with a single instance.
204
204
*/
205
- static findById < T extends Model < T > > ( identifier ?: number | string , options ?: IFindOptions < T > ) : Promise < T | null > ;
205
+ static findById < T extends Model < T > > ( this : ( new ( ) => T ) , identifier ?: number | string , options ?: IFindOptions < T > ) : Promise < T | null > ;
206
206
207
- static findByPrimary < T extends Model < T > > ( identifier ?: number | string , options ?: IFindOptions < T > ) : Promise < T | null > ;
207
+ static findByPrimary < T extends Model < T > > ( this : ( new ( ) => T ) , identifier ?: number | string , options ?: IFindOptions < T > ) : Promise < T | null > ;
208
208
209
209
/**
210
210
* Search for a single instance. This applies LIMIT 1, so the listener will always be called with a single
211
211
* instance.
212
212
*/
213
- static findOne < T extends Model < T > > ( options ?: IFindOptions < T > ) : Promise < T | null > ;
213
+ static findOne < T extends Model < T > > ( this : ( new ( ) => T ) , options ?: IFindOptions < T > ) : Promise < T | null > ;
214
214
215
- static find < T extends Model < T > > ( options ?: IFindOptions < T > ) : Promise < T | null > ;
215
+ static find < T extends Model < T > > ( this : ( new ( ) => T ) , options ?: IFindOptions < T > ) : Promise < T | null > ;
216
216
217
217
/**
218
218
* Run an aggregation method on the specified field
@@ -267,9 +267,9 @@ export declare abstract class Model<T> extends Hooks {
267
267
* without
268
268
* profiles will be counted
269
269
*/
270
- static findAndCount < T extends Model < T > > ( options ?: IFindOptions < T > ) : Promise < { rows : T [ ] , count : number } > ;
270
+ static findAndCount < T extends Model < T > > ( this : ( new ( ) => T ) , options ?: IFindOptions < T > ) : Promise < { rows : T [ ] , count : number } > ;
271
271
272
- static findAndCountAll < T extends Model < T > > ( options ?: IFindOptions < T > ) : Promise < { rows : T [ ] , count : number } > ;
272
+ static findAndCountAll < T extends Model < T > > ( this : ( new ( ) => T ) , options ?: IFindOptions < T > ) : Promise < { rows : T [ ] , count : number } > ;
273
273
274
274
/**
275
275
* Find the maximum value of field
@@ -289,30 +289,35 @@ export declare abstract class Model<T> extends Hooks {
289
289
/**
290
290
* Builds a new model instance. Values is an object of key value pairs, must be defined but can be empty.
291
291
*/
292
- static build < T extends Model < T > > ( record ?: any , options ?: IBuildOptions ) : T ;
293
- static build < T extends Model < T > , A > ( record ?: A , options ?: IBuildOptions ) : T ;
292
+ static build < T extends Model < T > > ( this : ( new ( ) => T ) , record ?: any , options ?: IBuildOptions ) : T ;
293
+ static build < T extends Model < T > , A > ( this : ( new ( ) => T ) , record ?: A , options ?: IBuildOptions ) : T ;
294
+ static build < A > ( this : ( new ( ) => T ) , record ?: A , options ?: IBuildOptions ) : T ;
294
295
295
296
/**
296
297
* Undocumented bulkBuild
297
298
*/
298
- static bulkBuild < T extends Model < T > > ( records : any [ ] , options ?: IBuildOptions ) : T [ ] ;
299
- static bulkBuild < T extends Model < T > , A > ( records : A [ ] , options ?: IBuildOptions ) : T [ ] ;
299
+ static bulkBuild < T extends Model < T > > ( this : ( new ( ) => T ) , records : any [ ] , options ?: IBuildOptions ) : T [ ] ;
300
+ static bulkBuild < T extends Model < T > , A > ( this : ( new ( ) => T ) , records : A [ ] , options ?: IBuildOptions ) : T [ ] ;
301
+ static bulkBuild < A > ( this : ( new ( ) => T ) , records : A [ ] , options ?: IBuildOptions ) : T [ ] ;
300
302
301
303
/**
302
304
* Builds a new model instance and calls save on it.
303
305
*/
304
- static create < T extends Model < T > > ( values ?: any , options ?: ICreateOptions ) : Promise < T > ;
305
- static create < T extends Model < T > , A > ( values ?: A , options ?: ICreateOptions ) : Promise < T > ;
306
+ static create < T extends Model < T > > ( this : ( new ( ) => T ) , values ?: any , options ?: ICreateOptions ) : Promise < T > ;
307
+ static create < T extends Model < T > , A > ( this : ( new ( ) => T ) , values ?: A , options ?: ICreateOptions ) : Promise < T > ;
308
+ static create < A > ( this : ( new ( ) => T ) , values ?: A , options ?: ICreateOptions ) : Promise < T > ;
306
309
307
310
/**
308
311
* Find a row that matches the query, or build (but don't save) the row if none is found.
309
312
* The successfull result of the promise will be (instance, initialized) - Make sure to use .spread()
310
313
*/
311
- static findOrInitialize < T extends Model < T > > ( options : IFindOrInitializeOptions < any > ) : Promise < [ T , boolean ] > ;
312
- static findOrInitialize < T extends Model < T > , A > ( options : IFindOrInitializeOptions < A > ) : Promise < [ T , boolean ] > ;
314
+ static findOrInitialize < T extends Model < T > > ( this : ( new ( ) => T ) , options : IFindOrInitializeOptions < any > ) : Promise < [ T , boolean ] > ;
315
+ static findOrInitialize < T extends Model < T > , A > ( this : ( new ( ) => T ) , options : IFindOrInitializeOptions < A > ) : Promise < [ T , boolean ] > ;
316
+ static findOrInitialize < A > ( this : ( new ( ) => T ) , options : IFindOrInitializeOptions < A > ) : Promise < [ T , boolean ] > ;
313
317
314
- static findOrBuild < T extends Model < T > > ( options : IFindOrInitializeOptions < any > ) : Promise < [ T , boolean ] > ;
315
- static findOrBuild < T extends Model < T > , A > ( options : IFindOrInitializeOptions < A > ) : Promise < [ T , boolean ] > ;
318
+ static findOrBuild < T extends Model < T > > ( this : ( new ( ) => T ) , options : IFindOrInitializeOptions < any > ) : Promise < [ T , boolean ] > ;
319
+ static findOrBuild < T extends Model < T > , A > ( this : ( new ( ) => T ) , options : IFindOrInitializeOptions < A > ) : Promise < [ T , boolean ] > ;
320
+ static findOrBuild < A > ( this : ( new ( ) => T ) , options : IFindOrInitializeOptions < A > ) : Promise < [ T , boolean ] > ;
316
321
317
322
/**
318
323
* Find a row that matches the query, or build and save the row if none is found
@@ -325,15 +330,17 @@ export declare abstract class Model<T> extends Hooks {
325
330
* an instance of sequelize.TimeoutError will be thrown instead. If a transaction is created, a savepoint
326
331
* will be created instead, and any unique constraint violation will be handled internally.
327
332
*/
328
- static findOrCreate < T extends Model < T > > ( options : IFindOrInitializeOptions < any > ) : Promise < [ T , boolean ] > ;
329
- static findOrCreate < T extends Model < T > , A > ( options : IFindOrInitializeOptions < A > ) : Promise < [ T , boolean ] > ;
333
+ static findOrCreate < T extends Model < T > > ( this : ( new ( ) => T ) , options : IFindOrInitializeOptions < any > ) : Promise < [ T , boolean ] > ;
334
+ static findOrCreate < T extends Model < T > , A > ( this : ( new ( ) => T ) , options : IFindOrInitializeOptions < A > ) : Promise < [ T , boolean ] > ;
335
+ static findOrCreate < A > ( this : ( new ( ) => T ) , options : IFindOrInitializeOptions < A > ) : Promise < [ T , boolean ] > ;
330
336
331
337
/**
332
338
* A more performant findOrCreate that will not work under a transaction (at least not in postgres)
333
339
* Will execute a find call, if empty then attempt to create, if unique constraint then attempt to find again
334
340
*/
335
- static findCreateFind < T extends Model < T > > ( options : IFindCreateFindOptions < any > ) : Promise < [ T , boolean ] > ;
336
- static findCreateFind < T extends Model < T > , A > ( options : IFindCreateFindOptions < A > ) : Promise < [ T , boolean ] > ;
341
+ static findCreateFind < T extends Model < T > > ( this : ( new ( ) => T ) , options : IFindCreateFindOptions < any > ) : Promise < [ T , boolean ] > ;
342
+ static findCreateFind < T extends Model < T > , A > ( this : ( new ( ) => T ) , options : IFindCreateFindOptions < A > ) : Promise < [ T , boolean ] > ;
343
+ static findCreateFind < A > ( this : ( new ( ) => T ) , options : IFindCreateFindOptions < A > ) : Promise < [ T , boolean ] > ;
337
344
338
345
/**
339
346
* Insert or update a single row. An update will be executed if a row which matches the supplied values on
@@ -369,8 +376,9 @@ export declare abstract class Model<T> extends Hooks {
369
376
*
370
377
* @param records List of objects (key/value pairs) to create instances from
371
378
*/
372
- static bulkCreate < T extends Model < T > > ( records : any [ ] , options ?: BulkCreateOptions ) : Promise < T [ ] > ;
373
- static bulkCreate < T extends Model < T > , A > ( records : A [ ] , options ?: BulkCreateOptions ) : Promise < T [ ] > ;
379
+ static bulkCreate < T extends Model < T > > ( this : ( new ( ) => T ) , records : any [ ] , options ?: BulkCreateOptions ) : Promise < T [ ] > ;
380
+ static bulkCreate < T extends Model < T > , A > ( this : ( new ( ) => T ) , records : A [ ] , options ?: BulkCreateOptions ) : Promise < T [ ] > ;
381
+ static bulkCreate < A > ( this : ( new ( ) => T ) , records : A [ ] , options ?: BulkCreateOptions ) : Promise < T [ ] > ;
374
382
375
383
/**
376
384
* Truncate all instances of the model. This is a convenient method for Model.destroy({ truncate: true }).
@@ -394,8 +402,9 @@ export declare abstract class Model<T> extends Hooks {
394
402
* elements. The first element is always the number of affected rows, while the second element is the actual
395
403
* affected rows (only supported in postgres with `options.returning` true.)
396
404
*/
397
- static update < T extends Model < T > > ( values : any , options : UpdateOptions ) : Promise < [ number , Array < T > ] > ;
398
- static update < T extends Model < T > , A > ( values : A , options : UpdateOptions ) : Promise < [ number , Array < T > ] > ;
405
+ static update < T extends Model < T > > ( this : ( new ( ) => T ) , values : any , options : UpdateOptions ) : Promise < [ number , Array < T > ] > ;
406
+ static update < T extends Model < T > , A > ( this : ( new ( ) => T ) , values : A , options : UpdateOptions ) : Promise < [ number , Array < T > ] > ;
407
+ static update < A > ( this : ( new ( ) => T ) , values : A , options : UpdateOptions ) : Promise < [ number , Array < T > ] > ;
399
408
400
409
/**
401
410
* Run a describe query on the table. The result will be return to the listener as a hash of attributes and
@@ -406,7 +415,7 @@ export declare abstract class Model<T> extends Hooks {
406
415
/**
407
416
* Unscope the model
408
417
*/
409
- static unscoped ( ) : typeof Model ;
418
+ static unscoped < T extends Model < T > > ( this : ( new ( ) => T ) ) : typeof T ;
410
419
411
420
/**
412
421
* A reference to the sequelize instance
0 commit comments