2017-12-14 17:38:41 +01:00
|
|
|
import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript'
|
|
|
|
import { AccountModel } from '../account/account'
|
2017-12-12 17:53:50 +01:00
|
|
|
|
2019-04-23 09:50:57 +02:00
|
|
|
@DefaultScope(() => ({
|
2017-12-14 17:38:41 +01:00
|
|
|
include: [
|
|
|
|
{
|
2019-04-23 09:50:57 +02:00
|
|
|
model: AccountModel,
|
2017-12-14 17:38:41 +01:00
|
|
|
required: true
|
|
|
|
}
|
|
|
|
]
|
2019-04-23 09:50:57 +02:00
|
|
|
}))
|
2017-12-12 17:53:50 +01:00
|
|
|
@Table({
|
2019-04-26 09:16:43 +02:00
|
|
|
tableName: 'application',
|
|
|
|
timestamps: false
|
2017-12-12 17:53:50 +01:00
|
|
|
})
|
|
|
|
export class ApplicationModel extends Model<ApplicationModel> {
|
|
|
|
|
|
|
|
@AllowNull(false)
|
|
|
|
@Default(0)
|
|
|
|
@IsInt
|
|
|
|
@Column
|
|
|
|
migrationVersion: number
|
|
|
|
|
2017-12-14 17:38:41 +01:00
|
|
|
@HasOne(() => AccountModel, {
|
|
|
|
foreignKey: {
|
|
|
|
allowNull: true
|
|
|
|
},
|
|
|
|
onDelete: 'cascade'
|
|
|
|
})
|
|
|
|
Account: AccountModel
|
|
|
|
|
2017-12-12 17:53:50 +01:00
|
|
|
static countTotal () {
|
|
|
|
return ApplicationModel.count()
|
|
|
|
}
|
2017-12-14 17:38:41 +01:00
|
|
|
|
|
|
|
static load () {
|
|
|
|
return ApplicationModel.findOne()
|
|
|
|
}
|
2016-09-26 22:36:36 +02:00
|
|
|
}
|