1 import { BelongsTo, Column, CreatedAt, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript'
2 import { SortType } from '../../helpers/utils'
3 import { getSortOnModel } from '../utils'
4 import { VideoModel } from './video'
7 tableName: 'videoBlacklist',
10 fields: [ 'videoId' ],
15 export class VideoBlacklistModel extends Model<VideoBlacklistModel> {
23 @ForeignKey(() => VideoModel)
27 @BelongsTo(() => VideoModel, {
35 static listForApi (start: number, count: number, sort: SortType) {
39 order: [ getSortOnModel(sort.sortModel, sort.sortValue) ],
40 include: [ { model: VideoModel } ]
43 return VideoBlacklistModel.findAndCountAll(query)
44 .then(({ rows, count }) => {
52 static loadByVideoId (id: number) {
59 return VideoBlacklistModel.findOne(query)
63 const video = this.Video
67 videoId: this.videoId,
68 createdAt: this.createdAt,
69 updatedAt: this.updatedAt,
72 description: video.description,
73 duration: video.duration,
76 dislikes: video.dislikes,