1
0
Fork 0
peertube/server/models/abuse/video-abuse.ts

64 lines
1.1 KiB
TypeScript
Raw Normal View History

2020-07-01 10:05:30 -04:00
import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript'
import { VideoDetails } from '@shared/models'
import { VideoModel } from '../video/video'
import { AbuseModel } from './abuse'
@Table({
tableName: 'videoAbuse',
indexes: [
{
fields: [ 'abuseId' ]
},
{
fields: [ 'videoId' ]
}
]
})
2020-12-08 08:30:29 -05:00
export class VideoAbuseModel extends Model {
2020-07-01 10:05:30 -04:00
@CreatedAt
createdAt: Date
@UpdatedAt
updatedAt: Date
@AllowNull(true)
@Default(null)
@Column
startAt: number
@AllowNull(true)
@Default(null)
@Column
endAt: number
@AllowNull(true)
@Default(null)
@Column(DataType.JSONB)
deletedVideo: VideoDetails
@ForeignKey(() => AbuseModel)
@Column
abuseId: number
@BelongsTo(() => AbuseModel, {
foreignKey: {
allowNull: false
},
onDelete: 'cascade'
})
Abuse: AbuseModel
@ForeignKey(() => VideoModel)
@Column
videoId: number
@BelongsTo(() => VideoModel, {
foreignKey: {
allowNull: true
},
onDelete: 'set null'
})
Video: VideoModel
}