mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-09-11 21:47:09 +03:00
findById -> findByPk
This commit is contained in:
parent
374c1db98c
commit
9b39106d57
@ -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",
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -117,7 +117,7 @@ export class VideoFileModel extends Model<VideoFileModel> {
|
||||
]
|
||||
}
|
||||
|
||||
return VideoFileModel.findById(id, options)
|
||||
return VideoFileModel.findByPk(id, options)
|
||||
}
|
||||
|
||||
static async getStats () {
|
||||
|
@ -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) {
|
||||
|
@ -110,7 +110,7 @@ export class VideoStreamingPlaylistModel extends Model<VideoStreamingPlaylistMod
|
||||
]
|
||||
}
|
||||
|
||||
return VideoStreamingPlaylistModel.findById(id, options)
|
||||
return VideoStreamingPlaylistModel.findByPk(id, options)
|
||||
}
|
||||
|
||||
static getHlsPlaylistFilename (resolution: number) {
|
||||
|
@ -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) {
|
||||
|
@ -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 () {
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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 () {
|
||||
|
16
yarn.lock
16
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"
|
||||
|
Loading…
Reference in New Issue
Block a user