aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/application
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/application')
-rw-r--r--server/models/application/application.ts23
1 files changed, 22 insertions, 1 deletions
diff --git a/server/models/application/application.ts b/server/models/application/application.ts
index 9fc07e850..854a5fb36 100644
--- a/server/models/application/application.ts
+++ b/server/models/application/application.ts
@@ -1,5 +1,14 @@
1import { AllowNull, Column, Default, IsInt, Model, Table } from 'sequelize-typescript' 1import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript'
2import { AccountModel } from '../account/account'
2 3
4@DefaultScope({
5 include: [
6 {
7 model: () => AccountModel,
8 required: true
9 }
10 ]
11})
3@Table({ 12@Table({
4 tableName: 'application' 13 tableName: 'application'
5}) 14})
@@ -11,7 +20,19 @@ export class ApplicationModel extends Model<ApplicationModel> {
11 @Column 20 @Column
12 migrationVersion: number 21 migrationVersion: number
13 22
23 @HasOne(() => AccountModel, {
24 foreignKey: {
25 allowNull: true
26 },
27 onDelete: 'cascade'
28 })
29 Account: AccountModel
30
14 static countTotal () { 31 static countTotal () {
15 return ApplicationModel.count() 32 return ApplicationModel.count()
16 } 33 }
34
35 static load () {
36 return ApplicationModel.findOne()
37 }
17} 38}