1
0
Fork 0
peertube/server/models/application/application.ts

39 lines
709 B
TypeScript
Raw Normal View History

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