1
0
Fork 0
peertube/server/models/application/application.ts
2017-12-19 10:53:16 +01:00

38 lines
709 B
TypeScript

import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript'
import { AccountModel } from '../account/account'
@DefaultScope({
include: [
{
model: () => AccountModel,
required: true
}
]
})
@Table({
tableName: 'application'
})
export class ApplicationModel extends Model<ApplicationModel> {
@AllowNull(false)
@Default(0)
@IsInt
@Column
migrationVersion: number
@HasOne(() => AccountModel, {
foreignKey: {
allowNull: true
},
onDelete: 'cascade'
})
Account: AccountModel
static countTotal () {
return ApplicationModel.count()
}
static load () {
return ApplicationModel.findOne()
}
}