aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-02-21 14:28:06 +0100
committerChocobozzz <me@florianbigard.com>2019-02-21 14:40:10 +0100
commit9b39106d5757caf221a88e42e05167a6fac479c6 (patch)
treece3ac7907135d82ad13abf648eff4f963448227e /server/models
parent374c1db98cf22527f5b362c70d3c50e3be4c8885 (diff)
downloadPeerTube-9b39106d5757caf221a88e42e05167a6fac479c6.tar.gz
PeerTube-9b39106d5757caf221a88e42e05167a6fac479c6.tar.zst
PeerTube-9b39106d5757caf221a88e42e05167a6fac479c6.zip
findById -> findByPk
Diffstat (limited to 'server/models')
-rw-r--r--server/models/account/account.ts3
-rw-r--r--server/models/account/user.ts2
-rw-r--r--server/models/activitypub/actor.ts2
-rw-r--r--server/models/video/video-change-ownership.ts2
-rw-r--r--server/models/video/video-channel.ts6
-rw-r--r--server/models/video/video-file.ts2
-rw-r--r--server/models/video/video-import.ts2
-rw-r--r--server/models/video/video-streaming-playlist.ts2
-rw-r--r--server/models/video/video.ts2
9 files changed, 11 insertions, 12 deletions
diff --git a/server/models/account/account.ts b/server/models/account/account.ts
index 747b51afb..ee22d8528 100644
--- a/server/models/account/account.ts
+++ b/server/models/account/account.ts
@@ -24,7 +24,6 @@ import { getSort, throwIfNotValid } from '../utils'
24import { VideoChannelModel } from '../video/video-channel' 24import { VideoChannelModel } from '../video/video-channel'
25import { VideoCommentModel } from '../video/video-comment' 25import { VideoCommentModel } from '../video/video-comment'
26import { UserModel } from './user' 26import { UserModel } from './user'
27import * as Bluebird from '../../helpers/custom-validators/accounts'
28import { CONFIG } from '../../initializers' 27import { CONFIG } from '../../initializers'
29 28
30@DefaultScope({ 29@DefaultScope({
@@ -136,7 +135,7 @@ export class AccountModel extends Model<AccountModel> {
136 } 135 }
137 136
138 static load (id: number, transaction?: Sequelize.Transaction) { 137 static load (id: number, transaction?: Sequelize.Transaction) {
139 return AccountModel.findById(id, { transaction }) 138 return AccountModel.findByPk(id, { transaction })
140 } 139 }
141 140
142 static loadByUUID (uuid: string) { 141 static loadByUUID (uuid: string) {
diff --git a/server/models/account/user.ts b/server/models/account/user.ts
index 017a96657..8aff9f497 100644
--- a/server/models/account/user.ts
+++ b/server/models/account/user.ts
@@ -341,7 +341,7 @@ export class UserModel extends Model<UserModel> {
341 } 341 }
342 342
343 static loadById (id: number) { 343 static loadById (id: number) {
344 return UserModel.findById(id) 344 return UserModel.findByPk(id)
345 } 345 }
346 346
347 static loadByUsername (username: string) { 347 static loadByUsername (username: string) {
diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts
index dda57a8ba..49f82023b 100644
--- a/server/models/activitypub/actor.ts
+++ b/server/models/activitypub/actor.ts
@@ -265,7 +265,7 @@ export class ActorModel extends Model<ActorModel> {
265 VideoChannel: VideoChannelModel 265 VideoChannel: VideoChannelModel
266 266
267 static load (id: number) { 267 static load (id: number) {
268 return ActorModel.unscoped().findById(id) 268 return ActorModel.unscoped().findByPk(id)
269 } 269 }
270 270
271 static loadAccountActorByVideoId (videoId: number, transaction: Sequelize.Transaction) { 271 static loadAccountActorByVideoId (videoId: number, transaction: Sequelize.Transaction) {
diff --git a/server/models/video/video-change-ownership.ts b/server/models/video/video-change-ownership.ts
index 48c07728f..85e688c4f 100644
--- a/server/models/video/video-change-ownership.ts
+++ b/server/models/video/video-change-ownership.ts
@@ -110,7 +110,7 @@ export class VideoChangeOwnershipModel extends Model<VideoChangeOwnershipModel>
110 } 110 }
111 111
112 static load (id: number) { 112 static load (id: number) {
113 return VideoChangeOwnershipModel.scope(ScopeNames.FULL).findById(id) 113 return VideoChangeOwnershipModel.scope(ScopeNames.FULL).findByPk(id)
114 } 114 }
115 115
116 toFormattedJSON (): VideoChangeOwnership { 116 toFormattedJSON (): VideoChangeOwnership {
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts
index 91dd0440c..2426b3de6 100644
--- a/server/models/video/video-channel.ts
+++ b/server/models/video/video-channel.ts
@@ -320,7 +320,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
320 static loadByIdAndPopulateAccount (id: number) { 320 static loadByIdAndPopulateAccount (id: number) {
321 return VideoChannelModel.unscoped() 321 return VideoChannelModel.unscoped()
322 .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ]) 322 .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ])
323 .findById(id) 323 .findByPk(id)
324 } 324 }
325 325
326 static loadByIdAndAccount (id: number, accountId: number) { 326 static loadByIdAndAccount (id: number, accountId: number) {
@@ -339,7 +339,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
339 static loadAndPopulateAccount (id: number) { 339 static loadAndPopulateAccount (id: number) {
340 return VideoChannelModel.unscoped() 340 return VideoChannelModel.unscoped()
341 .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ]) 341 .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ])
342 .findById(id) 342 .findByPk(id)
343 } 343 }
344 344
345 static loadByUUIDAndPopulateAccount (uuid: string) { 345 static loadByUUIDAndPopulateAccount (uuid: string) {
@@ -439,7 +439,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
439 439
440 return VideoChannelModel.unscoped() 440 return VideoChannelModel.unscoped()
441 .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT, ScopeNames.WITH_VIDEOS ]) 441 .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT, ScopeNames.WITH_VIDEOS ])
442 .findById(id, options) 442 .findByPk(id, options)
443 } 443 }
444 444
445 toFormattedJSON (): VideoChannel { 445 toFormattedJSON (): VideoChannel {
diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts
index 7d1e371b9..b861b0704 100644
--- a/server/models/video/video-file.ts
+++ b/server/models/video/video-file.ts
@@ -117,7 +117,7 @@ export class VideoFileModel extends Model<VideoFileModel> {
117 ] 117 ]
118 } 118 }
119 119
120 return VideoFileModel.findById(id, options) 120 return VideoFileModel.findByPk(id, options)
121 } 121 }
122 122
123 static async getStats () { 123 static async getStats () {
diff --git a/server/models/video/video-import.ts b/server/models/video/video-import.ts
index c723e57c0..9bc0f17f5 100644
--- a/server/models/video/video-import.ts
+++ b/server/models/video/video-import.ts
@@ -115,7 +115,7 @@ export class VideoImportModel extends Model<VideoImportModel> {
115 } 115 }
116 116
117 static loadAndPopulateVideo (id: number) { 117 static loadAndPopulateVideo (id: number) {
118 return VideoImportModel.findById(id) 118 return VideoImportModel.findByPk(id)
119 } 119 }
120 120
121 static listUserVideoImportsForApi (userId: number, start: number, count: number, sort: string) { 121 static listUserVideoImportsForApi (userId: number, start: number, count: number, sort: string) {
diff --git a/server/models/video/video-streaming-playlist.ts b/server/models/video/video-streaming-playlist.ts
index bf6f7b0c4..e489f9b0e 100644
--- a/server/models/video/video-streaming-playlist.ts
+++ b/server/models/video/video-streaming-playlist.ts
@@ -110,7 +110,7 @@ export class VideoStreamingPlaylistModel extends Model<VideoStreamingPlaylistMod
110 ] 110 ]
111 } 111 }
112 112
113 return VideoStreamingPlaylistModel.findById(id, options) 113 return VideoStreamingPlaylistModel.findByPk(id, options)
114 } 114 }
115 115
116 static getHlsPlaylistFilename (resolution: number) { 116 static getHlsPlaylistFilename (resolution: number) {
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index fe81fab1a..4516b9c7b 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -1313,7 +1313,7 @@ export class VideoModel extends Model<VideoModel> {
1313 1313
1314 static loadWithFiles (id: number, t?: Sequelize.Transaction, logging?: boolean) { 1314 static loadWithFiles (id: number, t?: Sequelize.Transaction, logging?: boolean) {
1315 return VideoModel.scope([ ScopeNames.WITH_FILES, ScopeNames.WITH_STREAMING_PLAYLISTS ]) 1315 return VideoModel.scope([ ScopeNames.WITH_FILES, ScopeNames.WITH_STREAMING_PLAYLISTS ])
1316 .findById(id, { transaction: t, logging }) 1316 .findByPk(id, { transaction: t, logging })
1317 } 1317 }
1318 1318
1319 static loadByUUIDWithFile (uuid: string) { 1319 static loadByUUIDWithFile (uuid: string) {