findById -> findByPk
authorChocobozzz <me@florianbigard.com>
Thu, 21 Feb 2019 13:28:06 +0000 (14:28 +0100)
committerChocobozzz <me@florianbigard.com>
Thu, 21 Feb 2019 13:40:10 +0000 (14:40 +0100)
15 files changed:
package.json
server/initializers/migrations/0080-video-channels.ts
server/models/account/account.ts
server/models/account/user.ts
server/models/activitypub/actor.ts
server/models/video/video-change-ownership.ts
server/models/video/video-channel.ts
server/models/video/video-file.ts
server/models/video/video-import.ts
server/models/video/video-streaming-playlist.ts
server/models/video/video.ts
server/tests/api/check-params/user-subscriptions.ts
server/tests/api/server/email.ts
server/tests/api/server/follows.ts
yarn.lock

index a4a545b54db9c43719ad535fefee098f6f058ae0..fffbc8e32365c891ea92b2a96c6f19e09751349e 100644 (file)
     "reflect-metadata": "^0.1.12",
     "request": "^2.81.0",
     "scripty": "^1.5.0",
-    "sequelize": "4.41.2",
-    "sequelize-typescript": "0.6.6",
+    "sequelize": "4.42.0",
+    "sequelize-typescript": "0.6.7",
     "sharp": "^0.21.0",
     "sitemap": "^2.1.0",
     "socket.io": "^2.2.0",
index f197215176c14d876b0767e1f7887f4424933f4d..0e17a4ccde72937b3b4d93eb25401435d65ff527 100644 (file)
@@ -74,7 +74,7 @@ async function up (utils: {
   for (const rawVideo of rawVideos) {
     const videoChannel = await utils.db.VideoChannel.findOne({ where: { authorId: rawVideo.authorId } })
 
-    const video = await utils.db.Video.findById(rawVideo.id)
+    const video = await utils.db.Video.findByPk(rawVideo.id)
     video.channelId = videoChannel.id
     await video.save()
   }
index 747b51afbb5e58fbe5a146193c370f5fdc3b2641..ee22d85281898503fded712a66aa74814f98da37 100644 (file)
@@ -24,7 +24,6 @@ import { getSort, throwIfNotValid } from '../utils'
 import { VideoChannelModel } from '../video/video-channel'
 import { VideoCommentModel } from '../video/video-comment'
 import { UserModel } from './user'
-import * as Bluebird from '../../helpers/custom-validators/accounts'
 import { CONFIG } from '../../initializers'
 
 @DefaultScope({
@@ -136,7 +135,7 @@ export class AccountModel extends Model<AccountModel> {
   }
 
   static load (id: number, transaction?: Sequelize.Transaction) {
-    return AccountModel.findById(id, { transaction })
+    return AccountModel.findByPk(id, { transaction })
   }
 
   static loadByUUID (uuid: string) {
index 017a96657b0a0c6289b13cca65860000848e735a..8aff9f4972fa146b1534a78a45fa86fa03690398 100644 (file)
@@ -341,7 +341,7 @@ export class UserModel extends Model<UserModel> {
   }
 
   static loadById (id: number) {
-    return UserModel.findById(id)
+    return UserModel.findByPk(id)
   }
 
   static loadByUsername (username: string) {
index dda57a8ba172264933a03fee9bf9723c40debb05..49f82023b48ab9ba60749d97aec8010f43576853 100644 (file)
@@ -265,7 +265,7 @@ export class ActorModel extends Model<ActorModel> {
   VideoChannel: VideoChannelModel
 
   static load (id: number) {
-    return ActorModel.unscoped().findById(id)
+    return ActorModel.unscoped().findByPk(id)
   }
 
   static loadAccountActorByVideoId (videoId: number, transaction: Sequelize.Transaction) {
index 48c07728f66b9b87af81be3fdf5dbc2d555e04bf..85e688c4f3abd1a05ac48be114ad77d77ef83716 100644 (file)
@@ -110,7 +110,7 @@ export class VideoChangeOwnershipModel extends Model<VideoChangeOwnershipModel>
   }
 
   static load (id: number) {
-    return VideoChangeOwnershipModel.scope(ScopeNames.FULL).findById(id)
+    return VideoChangeOwnershipModel.scope(ScopeNames.FULL).findByPk(id)
   }
 
   toFormattedJSON (): VideoChangeOwnership {
index 91dd0440ce227c3cad43c44a3e7c1c37daeff6ad..2426b3de692fdec6866ad0e054a5b14611dedead 100644 (file)
@@ -320,7 +320,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
   static loadByIdAndPopulateAccount (id: number) {
     return VideoChannelModel.unscoped()
       .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ])
-      .findById(id)
+      .findByPk(id)
   }
 
   static loadByIdAndAccount (id: number, accountId: number) {
@@ -339,7 +339,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
   static loadAndPopulateAccount (id: number) {
     return VideoChannelModel.unscoped()
       .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ])
-      .findById(id)
+      .findByPk(id)
   }
 
   static loadByUUIDAndPopulateAccount (uuid: string) {
@@ -439,7 +439,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
 
     return VideoChannelModel.unscoped()
       .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT, ScopeNames.WITH_VIDEOS ])
-      .findById(id, options)
+      .findByPk(id, options)
   }
 
   toFormattedJSON (): VideoChannel {
index 7d1e371b9f5b310781100862d3182b743e69f945..b861b0704c0b809f6e8ad5cf03fa0cda0ffc87f4 100644 (file)
@@ -117,7 +117,7 @@ export class VideoFileModel extends Model<VideoFileModel> {
       ]
     }
 
-    return VideoFileModel.findById(id, options)
+    return VideoFileModel.findByPk(id, options)
   }
 
   static async getStats () {
index c723e57c0d20fe16f945b98db37811137f124418..9bc0f17f53efaa52b810a4678bb60aa38b41909e 100644 (file)
@@ -115,7 +115,7 @@ export class VideoImportModel extends Model<VideoImportModel> {
   }
 
   static loadAndPopulateVideo (id: number) {
-    return VideoImportModel.findById(id)
+    return VideoImportModel.findByPk(id)
   }
 
   static listUserVideoImportsForApi (userId: number, start: number, count: number, sort: string) {
index bf6f7b0c4c465ca0a07a2f7bbcd41e7edb7f9b37..e489f9b0e095ea75ec0128d49cf79553f0c282ed 100644 (file)
@@ -110,7 +110,7 @@ export class VideoStreamingPlaylistModel extends Model<VideoStreamingPlaylistMod
       ]
     }
 
-    return VideoStreamingPlaylistModel.findById(id, options)
+    return VideoStreamingPlaylistModel.findByPk(id, options)
   }
 
   static getHlsPlaylistFilename (resolution: number) {
index fe81fab1ae4a7e9626527423894734840f4d4fd8..4516b9c7b88d57b61b74dcd41903cd997c564ca9 100644 (file)
@@ -1313,7 +1313,7 @@ export class VideoModel extends Model<VideoModel> {
 
   static loadWithFiles (id: number, t?: Sequelize.Transaction, logging?: boolean) {
     return VideoModel.scope([ ScopeNames.WITH_FILES, ScopeNames.WITH_STREAMING_PLAYLISTS ])
-                     .findById(id, { transaction: t, logging })
+                     .findByPk(id, { transaction: t, logging })
   }
 
   static loadByUUIDWithFile (uuid: string) {
index 8a9ced7c1526408aae5e7ee66387f0a39cbb0351..04a3eb97c43cb7a80dac3d83e45e59c7d9402f33 100644 (file)
@@ -212,7 +212,7 @@ describe('Test user subscriptions API validators', function () {
     })
   })
 
-  describe('When checking if subscriptions exist', async function () {
+  describe('When checking if subscriptions exist', function () {
     const existPath = path + '/exist'
 
     it('Should fail with a non authenticated user', async function () {
index f8f16f54fce93cfed4afa543b6c97cde3213eb0c..164905651f2dd0793b7e63e0636337e6edd3477d 100644 (file)
@@ -142,7 +142,8 @@ describe('Test emails', function () {
     })
   })
 
-  describe('When blocking/unblocking user', async function () {
+  describe('When blocking/unblocking user', function () {
+
     it('Should send the notification email when blocking a user', async function () {
       this.timeout(10000)
 
index ad4c87c733351147abf657f88bcce801e1b6df8d..80f54b7adae058bf73f4db7dada5f6a5b0ef1daa 100644 (file)
@@ -241,7 +241,7 @@ describe('Test follows', function () {
     expect(res.body.data[0].name).to.equal('server3')
   })
 
-  describe('Should propagate data on a new following', async function () {
+  describe('Should propagate data on a new following', function () {
     let video4: Video
 
     before(async function () {
index 4f9cf9503040e16b4455c1e233c34e3143246fae..4e6a5285ba5f8b99ce046ef8fa1a56a180ce8fc2 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
@@ -7488,10 +7488,10 @@ send@0.16.2:
     range-parser "~1.2.0"
     statuses "~1.4.0"
 
-sequelize-typescript@0.6.6:
-  version "0.6.6"
-  resolved "https://registry.yarnpkg.com/sequelize-typescript/-/sequelize-typescript-0.6.6.tgz#926037b542dae9f4eff20609d095cc5e3a3640f3"
-  integrity sha512-WGJTaNuHyYwUM8itxZvMVLeNEb7xSjisbVN1Q5rxLaIf2w67Xaf1GX6Jb+9840bjcNPvMsKgC2aR88zmw7UlcQ==
+sequelize-typescript@0.6.7:
+  version "0.6.7"
+  resolved "https://registry.yarnpkg.com/sequelize-typescript/-/sequelize-typescript-0.6.7.tgz#372be979cbae060c554fdbaf2c2d8c93a0283303"
+  integrity sha512-ae21Gq9VOVXlIjnh2vLdL42Kev6r4LC82xOQ2fXo0lHzQvjFeH8/GaWUlpvYv57AOgc+ZnElbYFbSLKdT9ue0w==
   dependencies:
     "@types/bluebird" "3.5.18"
     "@types/node" "6.0.41"
@@ -7499,10 +7499,10 @@ sequelize-typescript@0.6.6:
     es6-shim "0.35.3"
     glob "7.1.2"
 
-sequelize@4.41.2:
-  version "4.41.2"
-  resolved "https://registry.yarnpkg.com/sequelize/-/sequelize-4.41.2.tgz#bb9ba30d72e9eeb883c9861cd0e2cac672010883"
-  integrity sha512-8vPf2R0o9iEmtzkqNzwFdblO+0Mu+RNxOdLeYGGqWGlp3cushLpQucAeSGPQgf2hQVZP5yOCM1ouZKTQ5FTlvA==
+sequelize@4.42.0:
+  version "4.42.0"
+  resolved "https://registry.yarnpkg.com/sequelize/-/sequelize-4.42.0.tgz#439467ba7bfe7d5afcc56d62b3e091860fbf18f3"
+  integrity sha512-qxAYnX4rcv7PbNtEidb56REpxNJCdbN0qyk1jb3+e6sE7OrmS0nYMU+MFVbNTJtZfSpOEEL1TX0TkMw+wzZBxg==
   dependencies:
     bluebird "^3.5.0"
     cls-bluebird "^2.1.0"