1 import { literal, Op } from 'sequelize'
2 import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Model, Table } from 'sequelize-typescript'
3 import { AttributesOnly } from '@shared/typescript-utils'
4 import { VideoModel } from './video'
7 tableName: 'videoView',
14 fields: [ 'startDate' ]
18 export class VideoViewModel extends Model<Partial<AttributesOnly<VideoViewModel>>> {
23 @Column(DataType.DATE)
27 @Column(DataType.DATE)
34 @ForeignKey(() => VideoModel)
38 @BelongsTo(() => VideoModel, {
46 static removeOldRemoteViewsHistory (beforeDate: string) {
53 [Op.in]: literal('(SELECT "id" FROM "video" WHERE "remote" IS TRUE)')
58 return VideoViewModel.destroy(query)