File tree Expand file tree Collapse file tree 3 files changed +16
-3
lines changed
Expand file tree Collapse file tree 3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 1- import { ModelOptions } from "sequelize" ;
1+ import { Model , ModelOptions } from "sequelize" ;
22
3- export interface TableOptions extends ModelOptions {
3+ export interface TableOptions < M extends Model = Model > extends ModelOptions < M > {
44 modelName ?: string ;
55
66 /**
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import {TableOptions} from "./table-options";
22import { Model } from "../model/model" ;
33import { setModelName , addOptions } from "../shared/model-service" ;
44
5- export function Table ( options : TableOptions ) : Function ;
5+ export function Table < M extends Model = Model > ( options : TableOptions < M > ) : Function ;
66export function Table ( target : Function ) : void ;
77export function Table ( arg : any ) : void | Function {
88
Original file line number Diff line number Diff line change @@ -10,3 +10,16 @@ export class User extends Model {
1010 @Column ( DataType . ARRAY ( DataType . STRING ) )
1111 myCol : string [ ] ;
1212}
13+
14+ @Table < Post > ( {
15+ hooks : {
16+ beforeUpdate : ( instance ) => {
17+ // without generic random will result in error
18+ instance . random = 4 ;
19+ } ,
20+ } ,
21+ } )
22+ export class Post extends Model {
23+ @Column ( DataType . INTEGER )
24+ random : number ;
25+ }
You can’t perform that action at this time.
0 commit comments