1 import { Op, Transaction } from 'sequelize'
2 import { AllowNull, BelongsTo, Column, CreatedAt, Default, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript'
3 import { MScheduleVideoUpdateFormattable, MScheduleVideoUpdate } from '@server/types/models'
4 import { AttributesOnly } from '@shared/typescript-utils'
5 import { VideoPrivacy } from '../../../shared/models/videos'
6 import { VideoModel } from './video'
9 tableName: 'scheduleVideoUpdate',
12 fields: [ 'videoId' ],
16 fields: [ 'updateAt' ]
20 export class ScheduleVideoUpdateModel extends Model<Partial<AttributesOnly<ScheduleVideoUpdateModel>>> {
30 privacy: VideoPrivacy.PUBLIC | VideoPrivacy.UNLISTED | VideoPrivacy.INTERNAL
38 @ForeignKey(() => VideoModel)
42 @BelongsTo(() => VideoModel, {
50 static areVideosToUpdate () {
61 return ScheduleVideoUpdateModel.findOne(query)
65 static listVideosToUpdate (transaction?: Transaction) {
75 return ScheduleVideoUpdateModel.findAll<MScheduleVideoUpdate>(query)
78 static deleteByVideoId (videoId: number, t: Transaction) {
86 return ScheduleVideoUpdateModel.destroy(query)
89 toFormattedJSON (this: MScheduleVideoUpdateFormattable) {
91 updateAt: this.updateAt,
92 privacy: this.privacy || undefined