From b49f22d8f9a52ab75fd38db2d377249eb58fa678 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 8 Dec 2020 14:30:29 +0100 Subject: Upgrade sequelize to v6 --- server/models/video/tag.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'server/models/video/tag.ts') diff --git a/server/models/video/tag.ts b/server/models/video/tag.ts index adbc4fb7d..d04205703 100644 --- a/server/models/video/tag.ts +++ b/server/models/video/tag.ts @@ -1,12 +1,11 @@ -import * as Bluebird from 'bluebird' -import { fn, QueryTypes, Transaction, col } from 'sequelize' +import { col, fn, QueryTypes, Transaction } from 'sequelize' import { AllowNull, BelongsToMany, Column, CreatedAt, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' +import { MTag } from '@server/types/models' +import { VideoPrivacy, VideoState } from '../../../shared/models/videos' import { isVideoTagValid } from '../../helpers/custom-validators/videos' import { throwIfNotValid } from '../utils' import { VideoModel } from './video' import { VideoTagModel } from './video-tag' -import { VideoPrivacy, VideoState } from '../../../shared/models/videos' -import { MTag } from '@server/types/models' @Table({ tableName: 'tag', @@ -22,7 +21,7 @@ import { MTag } from '@server/types/models' } ] }) -export class TagModel extends Model { +export class TagModel extends Model { @AllowNull(false) @Is('VideoTag', value => throwIfNotValid(value, isVideoTagValid, 'tag')) @@ -45,7 +44,7 @@ export class TagModel extends Model { static findOrCreateTags (tags: string[], transaction: Transaction): Promise { if (tags === null) return Promise.resolve([]) - const tasks: Bluebird[] = [] + const tasks: Promise[] = [] tags.forEach(tag => { const query = { where: { @@ -66,7 +65,7 @@ export class TagModel extends Model { } // threshold corresponds to how many video the field should have to be returned - static getRandomSamples (threshold: number, count: number): Bluebird { + static getRandomSamples (threshold: number, count: number): Promise { const query = 'SELECT tag.name FROM tag ' + 'INNER JOIN "videoTag" ON "videoTag"."tagId" = tag.id ' + 'INNER JOIN video ON video.id = "videoTag"."videoId" ' + -- cgit v1.2.3