1 import { values } from 'lodash'
2 import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
3 import { isVideoFileInfoHashValid, isVideoFileResolutionValid, isVideoFileSizeValid } from '../../helpers/custom-validators/videos'
4 import { CONSTRAINTS_FIELDS } from '../../initializers'
5 import { throwIfNotValid } from '../utils'
6 import { VideoModel } from './video'
9 tableName: 'videoFile',
15 fields: [ 'infoHash' ]
19 export class VideoFileModel extends Model<VideoFileModel> {
27 @Is('VideoFileResolution', value => throwIfNotValid(value, isVideoFileResolutionValid, 'resolution'))
32 @Is('VideoFileSize', value => throwIfNotValid(value, isVideoFileSizeValid, 'size'))
33 @Column(DataType.BIGINT)
37 @Column(DataType.ENUM(values(CONSTRAINTS_FIELDS.VIDEOS.EXTNAME)))
41 @Is('VideoFileSize', value => throwIfNotValid(value, isVideoFileInfoHashValid, 'info hash'))
45 @ForeignKey(() => VideoModel)
49 @BelongsTo(() => VideoModel, {