Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

findById -> findByPk

Chocobozzz9b39106d5757
diff --git a/package.json b/package.json
index a4a545b54d..fffbc8e323 100644
--- a/package.json
+++ b/package.json
@@ -142,8 +142,8 @@
"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",
diff --git a/server/initializers/migrations/0080-video-channels.ts b/server/initializers/migrations/0080-video-channels.ts
index f197215176..0e17a4ccde 100644
--- a/server/initializers/migrations/0080-video-channels.ts
+++ b/server/initializers/migrations/0080-video-channels.ts
@@ -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()
}
diff --git a/server/models/account/account.ts b/server/models/account/account.ts
index 747b51afbb..ee22d85281 100644
--- a/server/models/account/account.ts
+++ b/server/models/account/account.ts
@@ -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) {
diff --git a/server/models/account/user.ts b/server/models/account/user.ts
index 017a96657b..8aff9f4972 100644
--- a/server/models/account/user.ts
+++ b/server/models/account/user.ts
@@ -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) {
diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts
index dda57a8ba1..49f82023b4 100644
--- a/server/models/activitypub/actor.ts
+++ b/server/models/activitypub/actor.ts
@@ -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) {
diff --git a/server/models/video/video-change-ownership.ts b/server/models/video/video-change-ownership.ts
index 48c07728f6..85e688c4f3 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>
}
static load (id: number) {
- return VideoChangeOwnershipModel.scope(ScopeNames.FULL).findById(id)
+ return VideoChangeOwnershipModel.scope(ScopeNames.FULL).findByPk(id)
}
toFormattedJSON (): VideoChangeOwnership {
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts
index 91dd0440ce..2426b3de69 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> {
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 {
diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts
index 7d1e371b9f..b861b0704c 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> {
]
}
- return VideoFileModel.findById(id, options)
+ return VideoFileModel.findByPk(id, options)
}
static async getStats () {
diff --git a/server/models/video/video-import.ts b/server/models/video/video-import.ts
index c723e57c0d..9bc0f17f53 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> {
}
static loadAndPopulateVideo (id: number) {
- return VideoImportModel.findById(id)
+ return VideoImportModel.findByPk(id)
}
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 bf6f7b0c4c..e489f9b0e0 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
]
}
- return VideoStreamingPlaylistModel.findById(id, options)
+ return VideoStreamingPlaylistModel.findByPk(id, options)
}
static getHlsPlaylistFilename (resolution: number) {
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index fe81fab1ae..4516b9c7b8 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -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) {
diff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.ts
index 8a9ced7c15..04a3eb97c4 100644
--- a/server/tests/api/check-params/user-subscriptions.ts
+++ b/server/tests/api/check-params/user-subscriptions.ts
@@ -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 () {
diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts
index f8f16f54fc..164905651f 100644
--- a/server/tests/api/server/email.ts
+++ b/server/tests/api/server/email.ts
@@ -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)
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts
index ad4c87c733..80f54b7ada 100644
--- a/server/tests/api/server/follows.ts
+++ b/server/tests/api/server/follows.ts
@@ -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 () {
diff --git a/yarn.lock b/yarn.lock
index 4f9cf95030..4e6a5285ba 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -7488,10 +7488,10 @@ [email protected]:
range-parser "~1.2.0"
statuses "~1.4.0"
- version "0.6.6"
- resolved "https://registry.yarnpkg.com/sequelize-typescript/-/sequelize-typescript-0.6.6.tgz#926037b542dae9f4eff20609d095cc5e3a3640f3"
- integrity sha512-WGJTaNuHyYwUM8itxZvMVLeNEb7xSjisbVN1Q5rxLaIf2w67Xaf1GX6Jb+9840bjcNPvMsKgC2aR88zmw7UlcQ==
+ 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 @@ [email protected]:
es6-shim "0.35.3"
glob "7.1.2"
- version "4.41.2"
- resolved "https://registry.yarnpkg.com/sequelize/-/sequelize-4.41.2.tgz#bb9ba30d72e9eeb883c9861cd0e2cac672010883"
- integrity sha512-8vPf2R0o9iEmtzkqNzwFdblO+0Mu+RNxOdLeYGGqWGlp3cushLpQucAeSGPQgf2hQVZP5yOCM1ouZKTQ5FTlvA==
+ 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"