diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-18 11:28:17 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-24 16:26:20 +0200 |
commit | 1735c825726edaa0af5035cb6cbb0cc0db502c6d (patch) | |
tree | 7bbb442f2cb4d7be58a4e08d87f5974403a3047c /server/models/account/account-video-rate.ts | |
parent | e8bafea35bc930cb8ac5b2d521a188642a1adffe (diff) | |
download | PeerTube-1735c825726edaa0af5035cb6cbb0cc0db502c6d.tar.gz PeerTube-1735c825726edaa0af5035cb6cbb0cc0db502c6d.tar.zst PeerTube-1735c825726edaa0af5035cb6cbb0cc0db502c6d.zip |
Update sequelize
Diffstat (limited to 'server/models/account/account-video-rate.ts')
-rw-r--r-- | server/models/account/account-video-rate.ts | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/server/models/account/account-video-rate.ts b/server/models/account/account-video-rate.ts index 78a897a65..59f586b54 100644 --- a/server/models/account/account-video-rate.ts +++ b/server/models/account/account-video-rate.ts | |||
@@ -1,16 +1,15 @@ | |||
1 | import { values } from 'lodash' | 1 | import { values } from 'lodash' |
2 | import { Transaction, Op } from 'sequelize' | 2 | import { FindOptions, Op, Transaction } from 'sequelize' |
3 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' | 3 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' |
4 | import { IFindOptions } from 'sequelize-typescript/lib/interfaces/IFindOptions' | ||
5 | import { VideoRateType } from '../../../shared/models/videos' | 4 | import { VideoRateType } from '../../../shared/models/videos' |
6 | import { CONSTRAINTS_FIELDS, VIDEO_RATE_TYPES } from '../../initializers/constants' | 5 | import { CONSTRAINTS_FIELDS, VIDEO_RATE_TYPES } from '../../initializers/constants' |
7 | import { VideoModel } from '../video/video' | 6 | import { VideoModel } from '../video/video' |
8 | import { AccountModel } from './account' | 7 | import { AccountModel } from './account' |
9 | import { ActorModel } from '../activitypub/actor' | 8 | import { ActorModel } from '../activitypub/actor' |
10 | import { throwIfNotValid, getSort } from '../utils' | 9 | import { getSort, throwIfNotValid } from '../utils' |
11 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | 10 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' |
12 | import { AccountVideoRate } from '../../../shared' | 11 | import { AccountVideoRate } from '../../../shared' |
13 | import { VideoChannelModel, ScopeNames as VideoChannelScopeNames } from '../video/video-channel' | 12 | import { ScopeNames as VideoChannelScopeNames, VideoChannelModel } from '../video/video-channel' |
14 | 13 | ||
15 | /* | 14 | /* |
16 | Account rates per video. | 15 | Account rates per video. |
@@ -40,7 +39,7 @@ import { VideoChannelModel, ScopeNames as VideoChannelScopeNames } from '../vide | |||
40 | export class AccountVideoRateModel extends Model<AccountVideoRateModel> { | 39 | export class AccountVideoRateModel extends Model<AccountVideoRateModel> { |
41 | 40 | ||
42 | @AllowNull(false) | 41 | @AllowNull(false) |
43 | @Column(DataType.ENUM(values(VIDEO_RATE_TYPES))) | 42 | @Column(DataType.ENUM(...values(VIDEO_RATE_TYPES))) |
44 | type: VideoRateType | 43 | type: VideoRateType |
45 | 44 | ||
46 | @AllowNull(false) | 45 | @AllowNull(false) |
@@ -79,7 +78,7 @@ export class AccountVideoRateModel extends Model<AccountVideoRateModel> { | |||
79 | Account: AccountModel | 78 | Account: AccountModel |
80 | 79 | ||
81 | static load (accountId: number, videoId: number, transaction?: Transaction) { | 80 | static load (accountId: number, videoId: number, transaction?: Transaction) { |
82 | const options: IFindOptions<AccountVideoRateModel> = { | 81 | const options: FindOptions = { |
83 | where: { | 82 | where: { |
84 | accountId, | 83 | accountId, |
85 | videoId | 84 | videoId |
@@ -97,7 +96,7 @@ export class AccountVideoRateModel extends Model<AccountVideoRateModel> { | |||
97 | type?: string, | 96 | type?: string, |
98 | accountId: number | 97 | accountId: number |
99 | }) { | 98 | }) { |
100 | const query: IFindOptions<AccountVideoRateModel> = { | 99 | const query: FindOptions = { |
101 | offset: options.start, | 100 | offset: options.start, |
102 | limit: options.count, | 101 | limit: options.count, |
103 | order: getSort(options.sort), | 102 | order: getSort(options.sort), |
@@ -123,7 +122,7 @@ export class AccountVideoRateModel extends Model<AccountVideoRateModel> { | |||
123 | } | 122 | } |
124 | 123 | ||
125 | static loadLocalAndPopulateVideo (rateType: VideoRateType, accountName: string, videoId: number, transaction?: Transaction) { | 124 | static loadLocalAndPopulateVideo (rateType: VideoRateType, accountName: string, videoId: number, transaction?: Transaction) { |
126 | const options: IFindOptions<AccountVideoRateModel> = { | 125 | const options: FindOptions = { |
127 | where: { | 126 | where: { |
128 | videoId, | 127 | videoId, |
129 | type: rateType | 128 | type: rateType |
@@ -155,7 +154,7 @@ export class AccountVideoRateModel extends Model<AccountVideoRateModel> { | |||
155 | } | 154 | } |
156 | 155 | ||
157 | static loadByUrl (url: string, transaction: Transaction) { | 156 | static loadByUrl (url: string, transaction: Transaction) { |
158 | const options: IFindOptions<AccountVideoRateModel> = { | 157 | const options: FindOptions = { |
159 | where: { | 158 | where: { |
160 | url | 159 | url |
161 | } | 160 | } |