diff options
author | Chocobozzz <me@florianbigard.com> | 2020-12-08 14:30:29 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-12-09 11:41:22 +0100 |
commit | b49f22d8f9a52ab75fd38db2d377249eb58fa678 (patch) | |
tree | a2825877d7b3b53454804a79c9d2a14c5d37385c /server/models/video/video-playlist.ts | |
parent | 6c8c15f914cd375da1db5d0cd4d924a86c53d4c1 (diff) | |
download | PeerTube-b49f22d8f9a52ab75fd38db2d377249eb58fa678.tar.gz PeerTube-b49f22d8f9a52ab75fd38db2d377249eb58fa678.tar.zst PeerTube-b49f22d8f9a52ab75fd38db2d377249eb58fa678.zip |
Upgrade sequelize to v6
Diffstat (limited to 'server/models/video/video-playlist.ts')
-rw-r--r-- | server/models/video/video-playlist.ts | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.ts index 9f9e0b069..93ecf8cea 100644 --- a/server/models/video/video-playlist.ts +++ b/server/models/video/video-playlist.ts | |||
@@ -1,4 +1,3 @@ | |||
1 | import * as Bluebird from 'bluebird' | ||
2 | import { join } from 'path' | 1 | import { join } from 'path' |
3 | import { FindOptions, literal, Op, ScopeOptions, Transaction, WhereOptions } from 'sequelize' | 2 | import { FindOptions, literal, Op, ScopeOptions, Transaction, WhereOptions } from 'sequelize' |
4 | import { | 3 | import { |
@@ -125,7 +124,6 @@ type AvailableForListOptions = { | |||
125 | ] | 124 | ] |
126 | }, | 125 | }, |
127 | [ScopeNames.AVAILABLE_FOR_LIST]: (options: AvailableForListOptions) => { | 126 | [ScopeNames.AVAILABLE_FOR_LIST]: (options: AvailableForListOptions) => { |
128 | |||
129 | let whereActor: WhereOptions = {} | 127 | let whereActor: WhereOptions = {} |
130 | 128 | ||
131 | const whereAnd: WhereOptions[] = [] | 129 | const whereAnd: WhereOptions[] = [] |
@@ -182,15 +180,13 @@ type AvailableForListOptions = { | |||
182 | [Op.and]: whereAnd | 180 | [Op.and]: whereAnd |
183 | } | 181 | } |
184 | 182 | ||
185 | const accountScope = { | ||
186 | method: [ AccountScopeNames.SUMMARY, { whereActor } as SummaryOptions ] | ||
187 | } | ||
188 | |||
189 | return { | 183 | return { |
190 | where, | 184 | where, |
191 | include: [ | 185 | include: [ |
192 | { | 186 | { |
193 | model: AccountModel.scope(accountScope), | 187 | model: AccountModel.scope({ |
188 | method: [ AccountScopeNames.SUMMARY, { whereActor } as SummaryOptions ] | ||
189 | }), | ||
194 | required: true | 190 | required: true |
195 | }, | 191 | }, |
196 | { | 192 | { |
@@ -217,7 +213,7 @@ type AvailableForListOptions = { | |||
217 | } | 213 | } |
218 | ] | 214 | ] |
219 | }) | 215 | }) |
220 | export class VideoPlaylistModel extends Model<VideoPlaylistModel> { | 216 | export class VideoPlaylistModel extends Model { |
221 | @CreatedAt | 217 | @CreatedAt |
222 | createdAt: Date | 218 | createdAt: Date |
223 | 219 | ||
@@ -367,7 +363,7 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> { | |||
367 | }) | 363 | }) |
368 | } | 364 | } |
369 | 365 | ||
370 | static listPlaylistIdsOf (accountId: number, videoIds: number[]): Bluebird<MVideoPlaylistIdWithElements[]> { | 366 | static listPlaylistIdsOf (accountId: number, videoIds: number[]): Promise<MVideoPlaylistIdWithElements[]> { |
371 | const query = { | 367 | const query = { |
372 | attributes: [ 'id' ], | 368 | attributes: [ 'id' ], |
373 | where: { | 369 | where: { |
@@ -392,7 +388,7 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> { | |||
392 | 388 | ||
393 | static doesPlaylistExist (url: string) { | 389 | static doesPlaylistExist (url: string) { |
394 | const query = { | 390 | const query = { |
395 | attributes: [], | 391 | attributes: [ 'id' ], |
396 | where: { | 392 | where: { |
397 | url | 393 | url |
398 | } | 394 | } |
@@ -403,7 +399,7 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> { | |||
403 | .then(e => !!e) | 399 | .then(e => !!e) |
404 | } | 400 | } |
405 | 401 | ||
406 | static loadWithAccountAndChannelSummary (id: number | string, transaction: Transaction): Bluebird<MVideoPlaylistFullSummary> { | 402 | static loadWithAccountAndChannelSummary (id: number | string, transaction: Transaction): Promise<MVideoPlaylistFullSummary> { |
407 | const where = buildWhereIdOrUUID(id) | 403 | const where = buildWhereIdOrUUID(id) |
408 | 404 | ||
409 | const query = { | 405 | const query = { |
@@ -416,7 +412,7 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> { | |||
416 | .findOne(query) | 412 | .findOne(query) |
417 | } | 413 | } |
418 | 414 | ||
419 | static loadWithAccountAndChannel (id: number | string, transaction: Transaction): Bluebird<MVideoPlaylistFull> { | 415 | static loadWithAccountAndChannel (id: number | string, transaction: Transaction): Promise<MVideoPlaylistFull> { |
420 | const where = buildWhereIdOrUUID(id) | 416 | const where = buildWhereIdOrUUID(id) |
421 | 417 | ||
422 | const query = { | 418 | const query = { |
@@ -429,7 +425,7 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> { | |||
429 | .findOne(query) | 425 | .findOne(query) |
430 | } | 426 | } |
431 | 427 | ||
432 | static loadByUrlAndPopulateAccount (url: string): Bluebird<MVideoPlaylistAccountThumbnail> { | 428 | static loadByUrlAndPopulateAccount (url: string): Promise<MVideoPlaylistAccountThumbnail> { |
433 | const query = { | 429 | const query = { |
434 | where: { | 430 | where: { |
435 | url | 431 | url |