]>
Commit | Line | Data |
---|---|---|
50d6de9c C |
1 | import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript' |
2 | import { AccountModel } from '../account/account' | |
3fd3ab2d | 3 | |
50d6de9c C |
4 | @DefaultScope({ |
5 | include: [ | |
6 | { | |
7 | model: () => AccountModel, | |
8 | required: true | |
9 | } | |
10 | ] | |
11 | }) | |
3fd3ab2d C |
12 | @Table({ |
13 | tableName: 'application' | |
14 | }) | |
15 | export class ApplicationModel extends Model<ApplicationModel> { | |
16 | ||
17 | @AllowNull(false) | |
18 | @Default(0) | |
19 | @IsInt | |
20 | @Column | |
21 | migrationVersion: number | |
22 | ||
50d6de9c C |
23 | @HasOne(() => AccountModel, { |
24 | foreignKey: { | |
25 | allowNull: true | |
26 | }, | |
27 | onDelete: 'cascade' | |
28 | }) | |
29 | Account: AccountModel | |
30 | ||
3fd3ab2d C |
31 | static countTotal () { |
32 | return ApplicationModel.count() | |
33 | } | |
50d6de9c C |
34 | |
35 | static load () { | |
36 | return ApplicationModel.findOne() | |
37 | } | |
00d6b0dd | 38 | } |