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/video/video-channel.ts | |
parent | e8bafea35bc930cb8ac5b2d521a188642a1adffe (diff) | |
download | PeerTube-1735c825726edaa0af5035cb6cbb0cc0db502c6d.tar.gz PeerTube-1735c825726edaa0af5035cb6cbb0cc0db502c6d.tar.zst PeerTube-1735c825726edaa0af5035cb6cbb0cc0db502c6d.zip |
Update sequelize
Diffstat (limited to 'server/models/video/video-channel.ts')
-rw-r--r-- | server/models/video/video-channel.ts | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index 5b5075344..901006dea 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts | |||
@@ -9,7 +9,6 @@ import { | |||
9 | DefaultScope, | 9 | DefaultScope, |
10 | ForeignKey, | 10 | ForeignKey, |
11 | HasMany, | 11 | HasMany, |
12 | IFindOptions, | ||
13 | Is, | 12 | Is, |
14 | Model, | 13 | Model, |
15 | Scopes, | 14 | Scopes, |
@@ -31,12 +30,12 @@ import { buildServerIdsFollowedBy, buildTrigramSearchIndex, createSimilarityAttr | |||
31 | import { VideoModel } from './video' | 30 | import { VideoModel } from './video' |
32 | import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers/constants' | 31 | import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers/constants' |
33 | import { ServerModel } from '../server/server' | 32 | import { ServerModel } from '../server/server' |
34 | import { DefineIndexesOptions } from 'sequelize' | 33 | import { FindOptions, ModelIndexesOptions, Op } from 'sequelize' |
35 | import { AvatarModel } from '../avatar/avatar' | 34 | import { AvatarModel } from '../avatar/avatar' |
36 | import { VideoPlaylistModel } from './video-playlist' | 35 | import { VideoPlaylistModel } from './video-playlist' |
37 | 36 | ||
38 | // FIXME: Define indexes here because there is an issue with TS and Sequelize.literal when called directly in the annotation | 37 | // FIXME: Define indexes here because there is an issue with TS and Sequelize.literal when called directly in the annotation |
39 | const indexes: DefineIndexesOptions[] = [ | 38 | const indexes: ModelIndexesOptions[] = [ |
40 | buildTrigramSearchIndex('video_channel_name_trigram', 'name'), | 39 | buildTrigramSearchIndex('video_channel_name_trigram', 'name'), |
41 | 40 | ||
42 | { | 41 | { |
@@ -69,7 +68,7 @@ type AvailableForListOptions = { | |||
69 | }) | 68 | }) |
70 | @Scopes({ | 69 | @Scopes({ |
71 | [ScopeNames.SUMMARY]: (withAccount = false) => { | 70 | [ScopeNames.SUMMARY]: (withAccount = false) => { |
72 | const base: IFindOptions<VideoChannelModel> = { | 71 | const base: FindOptions = { |
73 | attributes: [ 'name', 'description', 'id', 'actorId' ], | 72 | attributes: [ 'name', 'description', 'id', 'actorId' ], |
74 | include: [ | 73 | include: [ |
75 | { | 74 | { |
@@ -112,13 +111,13 @@ type AvailableForListOptions = { | |||
112 | }, | 111 | }, |
113 | model: ActorModel, | 112 | model: ActorModel, |
114 | where: { | 113 | where: { |
115 | [Sequelize.Op.or]: [ | 114 | [Op.or]: [ |
116 | { | 115 | { |
117 | serverId: null | 116 | serverId: null |
118 | }, | 117 | }, |
119 | { | 118 | { |
120 | serverId: { | 119 | serverId: { |
121 | [ Sequelize.Op.in ]: Sequelize.literal(inQueryInstanceFollow) | 120 | [ Op.in ]: Sequelize.literal(inQueryInstanceFollow) |
122 | } | 121 | } |
123 | } | 122 | } |
124 | ] | 123 | ] |
@@ -172,13 +171,13 @@ export class VideoChannelModel extends Model<VideoChannelModel> { | |||
172 | 171 | ||
173 | @AllowNull(true) | 172 | @AllowNull(true) |
174 | @Default(null) | 173 | @Default(null) |
175 | @Is('VideoChannelDescription', value => throwIfNotValid(value, isVideoChannelDescriptionValid, 'description')) | 174 | @Is('VideoChannelDescription', value => throwIfNotValid(value, isVideoChannelDescriptionValid, 'description', true)) |
176 | @Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_CHANNELS.DESCRIPTION.max)) | 175 | @Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_CHANNELS.DESCRIPTION.max)) |
177 | description: string | 176 | description: string |
178 | 177 | ||
179 | @AllowNull(true) | 178 | @AllowNull(true) |
180 | @Default(null) | 179 | @Default(null) |
181 | @Is('VideoChannelSupport', value => throwIfNotValid(value, isVideoChannelSupportValid, 'support')) | 180 | @Is('VideoChannelSupport', value => throwIfNotValid(value, isVideoChannelSupportValid, 'support', true)) |
182 | @Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_CHANNELS.SUPPORT.max)) | 181 | @Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_CHANNELS.SUPPORT.max)) |
183 | support: string | 182 | support: string |
184 | 183 | ||
@@ -313,7 +312,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> { | |||
313 | limit: options.count, | 312 | limit: options.count, |
314 | order: getSort(options.sort), | 313 | order: getSort(options.sort), |
315 | where: { | 314 | where: { |
316 | [Sequelize.Op.or]: [ | 315 | [Op.or]: [ |
317 | Sequelize.literal( | 316 | Sequelize.literal( |
318 | 'lower(immutable_unaccent("VideoChannelModel"."name")) % lower(immutable_unaccent(' + escapedSearch + '))' | 317 | 'lower(immutable_unaccent("VideoChannelModel"."name")) % lower(immutable_unaccent(' + escapedSearch + '))' |
319 | ), | 318 | ), |