From 3acc50844047a37698f0618fa235c138e386a053 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 23 Apr 2019 09:50:57 +0200 Subject: Upgrade sequelize --- server/models/video/video-caption.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'server/models/video/video-caption.ts') diff --git a/server/models/video/video-caption.ts b/server/models/video/video-caption.ts index 45c60e26b..76243bf48 100644 --- a/server/models/video/video-caption.ts +++ b/server/models/video/video-caption.ts @@ -12,7 +12,7 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { throwIfNotValid } from '../utils' +import { buildWhereIdOrUUID, throwIfNotValid } from '../utils' import { VideoModel } from './video' import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions' import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model' @@ -26,17 +26,17 @@ export enum ScopeNames { WITH_VIDEO_UUID_AND_REMOTE = 'WITH_VIDEO_UUID_AND_REMOTE' } -@Scopes({ +@Scopes(() => ({ [ScopeNames.WITH_VIDEO_UUID_AND_REMOTE]: { include: [ { attributes: [ 'uuid', 'remote' ], - model: () => VideoModel.unscoped(), + model: VideoModel.unscoped(), required: true } ] } -}) +})) @Table({ tableName: 'videoCaption', @@ -97,12 +97,9 @@ export class VideoCaptionModel extends Model { const videoInclude = { model: VideoModel.unscoped(), attributes: [ 'id', 'remote', 'uuid' ], - where: { } + where: buildWhereIdOrUUID(videoId) } - if (typeof videoId === 'string') videoInclude.where['uuid'] = videoId - else videoInclude.where['id'] = videoId - const query = { where: { language -- cgit v1.2.3