aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-07-11 16:01:56 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-07-11 16:01:56 +0200
commit0a6658fdcbd779ada8f3758048c326e997902d5a (patch)
tree5de40bf901db0299011104b1344783637b964eb0 /server/models/video
parente6d4b0ff2404dcf0b3a755c3fcc415ffeb6e754d (diff)
downloadPeerTube-0a6658fdcbd779ada8f3758048c326e997902d5a.tar.gz
PeerTube-0a6658fdcbd779ada8f3758048c326e997902d5a.tar.zst
PeerTube-0a6658fdcbd779ada8f3758048c326e997902d5a.zip
Use global uuid instead of remoteId for videos
Diffstat (limited to 'server/models/video')
-rw-r--r--server/models/video/tag.ts2
-rw-r--r--server/models/video/video-abuse-interface.ts2
-rw-r--r--server/models/video/video-abuse.ts4
-rw-r--r--server/models/video/video-blacklist-interface.ts4
-rw-r--r--server/models/video/video-blacklist.ts9
-rw-r--r--server/models/video/video-interface.ts23
-rw-r--r--server/models/video/video.ts100
7 files changed, 87 insertions, 57 deletions
diff --git a/server/models/video/tag.ts b/server/models/video/tag.ts
index 2992da56d..0c0757fc8 100644
--- a/server/models/video/tag.ts
+++ b/server/models/video/tag.ts
@@ -47,7 +47,7 @@ function associate (models) {
47 Tag.belongsToMany(models.Video, { 47 Tag.belongsToMany(models.Video, {
48 foreignKey: 'tagId', 48 foreignKey: 'tagId',
49 through: models.VideoTag, 49 through: models.VideoTag,
50 onDelete: 'cascade' 50 onDelete: 'CASCADE'
51 }) 51 })
52} 52}
53 53
diff --git a/server/models/video/video-abuse-interface.ts b/server/models/video/video-abuse-interface.ts
index d6724d36f..fa45aa5f9 100644
--- a/server/models/video/video-abuse-interface.ts
+++ b/server/models/video/video-abuse-interface.ts
@@ -20,7 +20,7 @@ export interface VideoAbuseClass {
20export interface VideoAbuseAttributes { 20export interface VideoAbuseAttributes {
21 reporterUsername: string 21 reporterUsername: string
22 reason: string 22 reason: string
23 videoId: string 23 videoId: number
24} 24}
25 25
26export interface VideoAbuseInstance extends VideoAbuseClass, VideoAbuseAttributes, Sequelize.Instance<VideoAbuseAttributes> { 26export interface VideoAbuseInstance extends VideoAbuseClass, VideoAbuseAttributes, Sequelize.Instance<VideoAbuseAttributes> {
diff --git a/server/models/video/video-abuse.ts b/server/models/video/video-abuse.ts
index ab1a3ea7d..f55a25e6a 100644
--- a/server/models/video/video-abuse.ts
+++ b/server/models/video/video-abuse.ts
@@ -96,7 +96,7 @@ function associate (models) {
96 name: 'reporterPodId', 96 name: 'reporterPodId',
97 allowNull: true 97 allowNull: true
98 }, 98 },
99 onDelete: 'cascade' 99 onDelete: 'CASCADE'
100 }) 100 })
101 101
102 VideoAbuse.belongsTo(models.Video, { 102 VideoAbuse.belongsTo(models.Video, {
@@ -104,7 +104,7 @@ function associate (models) {
104 name: 'videoId', 104 name: 'videoId',
105 allowNull: false 105 allowNull: false
106 }, 106 },
107 onDelete: 'cascade' 107 onDelete: 'CASCADE'
108 }) 108 })
109} 109}
110 110
diff --git a/server/models/video/video-blacklist-interface.ts b/server/models/video/video-blacklist-interface.ts
index 47a510231..cd9f19363 100644
--- a/server/models/video/video-blacklist-interface.ts
+++ b/server/models/video/video-blacklist-interface.ts
@@ -17,7 +17,7 @@ export namespace BlacklistedVideoMethods {
17 17
18 export type LoadById = (id: number) => Promise<BlacklistedVideoInstance> 18 export type LoadById = (id: number) => Promise<BlacklistedVideoInstance>
19 19
20 export type LoadByVideoId = (id: string) => Promise<BlacklistedVideoInstance> 20 export type LoadByVideoId = (id: number) => Promise<BlacklistedVideoInstance>
21} 21}
22 22
23export interface BlacklistedVideoClass { 23export interface BlacklistedVideoClass {
@@ -30,7 +30,7 @@ export interface BlacklistedVideoClass {
30} 30}
31 31
32export interface BlacklistedVideoAttributes { 32export interface BlacklistedVideoAttributes {
33 videoId: string 33 videoId: number
34} 34}
35 35
36export interface BlacklistedVideoInstance 36export interface BlacklistedVideoInstance
diff --git a/server/models/video/video-blacklist.ts b/server/models/video/video-blacklist.ts
index 8c42dbc21..4d1b45aa5 100644
--- a/server/models/video/video-blacklist.ts
+++ b/server/models/video/video-blacklist.ts
@@ -60,8 +60,11 @@ toFormatedJSON = function (this: BlacklistedVideoInstance) {
60 60
61function associate (models) { 61function associate (models) {
62 BlacklistedVideo.belongsTo(models.Video, { 62 BlacklistedVideo.belongsTo(models.Video, {
63 foreignKey: 'videoId', 63 foreignKey: {
64 onDelete: 'cascade' 64 name: 'videoId',
65 allowNull: false
66 },
67 onDelete: 'CASCADE'
65 }) 68 })
66} 69}
67 70
@@ -92,7 +95,7 @@ loadById = function (id: number) {
92 return BlacklistedVideo.findById(id) 95 return BlacklistedVideo.findById(id)
93} 96}
94 97
95loadByVideoId = function (id: string) { 98loadByVideoId = function (id: number) {
96 const query = { 99 const query = {
97 where: { 100 where: {
98 videoId: id 101 videoId: id
diff --git a/server/models/video/video-interface.ts b/server/models/video/video-interface.ts
index b836d6da6..2fabcd906 100644
--- a/server/models/video/video-interface.ts
+++ b/server/models/video/video-interface.ts
@@ -9,6 +9,7 @@ import { Video as FormatedVideo } from '../../../shared/models/videos/video.mode
9import { ResultList } from '../../../shared/models/result-list.model' 9import { ResultList } from '../../../shared/models/result-list.model'
10 10
11export type FormatedAddRemoteVideo = { 11export type FormatedAddRemoteVideo = {
12 uuid: string
12 name: string 13 name: string
13 category: number 14 category: number
14 licence: number 15 licence: number
@@ -16,7 +17,6 @@ export type FormatedAddRemoteVideo = {
16 nsfw: boolean 17 nsfw: boolean
17 description: string 18 description: string
18 infoHash: string 19 infoHash: string
19 remoteId: string
20 author: string 20 author: string
21 duration: number 21 duration: number
22 thumbnailData: string 22 thumbnailData: string
@@ -30,6 +30,7 @@ export type FormatedAddRemoteVideo = {
30} 30}
31 31
32export type FormatedUpdateRemoteVideo = { 32export type FormatedUpdateRemoteVideo = {
33 uuid: string
33 name: string 34 name: string
34 category: number 35 category: number
35 licence: number 36 licence: number
@@ -37,7 +38,6 @@ export type FormatedUpdateRemoteVideo = {
37 nsfw: boolean 38 nsfw: boolean
38 description: string 39 description: string
39 infoHash: string 40 infoHash: string
40 remoteId: string
41 author: string 41 author: string
42 duration: number 42 duration: number
43 tags: string[] 43 tags: string[]
@@ -80,10 +80,12 @@ export namespace VideoMethods {
80 sort: string 80 sort: string
81 ) => Promise< ResultList<VideoInstance> > 81 ) => Promise< ResultList<VideoInstance> >
82 82
83 export type Load = (id: string) => Promise<VideoInstance> 83 export type Load = (id: number) => Promise<VideoInstance>
84 export type LoadByHostAndRemoteId = (fromHost: string, remoteId: string) => Promise<VideoInstance> 84 export type LoadByUUID = (uuid: string) => Promise<VideoInstance>
85 export type LoadAndPopulateAuthor = (id: string) => Promise<VideoInstance> 85 export type LoadByHostAndUUID = (fromHost: string, uuid: string) => Promise<VideoInstance>
86 export type LoadAndPopulateAuthorAndPodAndTags = (id: string) => Promise<VideoInstance> 86 export type LoadAndPopulateAuthor = (id: number) => Promise<VideoInstance>
87 export type LoadAndPopulateAuthorAndPodAndTags = (id: number) => Promise<VideoInstance>
88 export type LoadByUUIDAndPopulateAuthorAndPodAndTags = (uuid: string) => Promise<VideoInstance>
87} 89}
88 90
89export interface VideoClass { 91export interface VideoClass {
@@ -102,19 +104,21 @@ export interface VideoClass {
102 getDurationFromFile: VideoMethods.GetDurationFromFile 104 getDurationFromFile: VideoMethods.GetDurationFromFile
103 list: VideoMethods.List 105 list: VideoMethods.List
104 listForApi: VideoMethods.ListForApi 106 listForApi: VideoMethods.ListForApi
105 loadByHostAndRemoteId: VideoMethods.LoadByHostAndRemoteId 107 loadByHostAndUUID: VideoMethods.LoadByHostAndUUID
106 listOwnedAndPopulateAuthorAndTags: VideoMethods.ListOwnedAndPopulateAuthorAndTags 108 listOwnedAndPopulateAuthorAndTags: VideoMethods.ListOwnedAndPopulateAuthorAndTags
107 listOwnedByAuthor: VideoMethods.ListOwnedByAuthor 109 listOwnedByAuthor: VideoMethods.ListOwnedByAuthor
108 load: VideoMethods.Load 110 load: VideoMethods.Load
111 loadByUUID: VideoMethods.LoadByUUID
109 loadAndPopulateAuthor: VideoMethods.LoadAndPopulateAuthor 112 loadAndPopulateAuthor: VideoMethods.LoadAndPopulateAuthor
110 loadAndPopulateAuthorAndPodAndTags: VideoMethods.LoadAndPopulateAuthorAndPodAndTags 113 loadAndPopulateAuthorAndPodAndTags: VideoMethods.LoadAndPopulateAuthorAndPodAndTags
114 loadByUUIDAndPopulateAuthorAndPodAndTags: VideoMethods.LoadByUUIDAndPopulateAuthorAndPodAndTags
111 searchAndPopulateAuthorAndPodAndTags: VideoMethods.SearchAndPopulateAuthorAndPodAndTags 115 searchAndPopulateAuthorAndPodAndTags: VideoMethods.SearchAndPopulateAuthorAndPodAndTags
112} 116}
113 117
114export interface VideoAttributes { 118export interface VideoAttributes {
119 uuid?: string
115 name: string 120 name: string
116 extname: string 121 extname: string
117 remoteId: string
118 category: number 122 category: number
119 licence: number 123 licence: number
120 language: number 124 language: number
@@ -125,13 +129,14 @@ export interface VideoAttributes {
125 views?: number 129 views?: number
126 likes?: number 130 likes?: number
127 dislikes?: number 131 dislikes?: number
132 remote: boolean
128 133
129 Author?: AuthorInstance 134 Author?: AuthorInstance
130 Tags?: TagInstance[] 135 Tags?: TagInstance[]
131} 136}
132 137
133export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.Instance<VideoAttributes> { 138export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.Instance<VideoAttributes> {
134 id: string 139 id: number
135 createdAt: Date 140 createdAt: Date
136 updatedAt: Date 141 updatedAt: Date
137 142
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 496385b35..3bb74bf6d 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -62,21 +62,23 @@ let generateThumbnailFromData: VideoMethods.GenerateThumbnailFromData
62let getDurationFromFile: VideoMethods.GetDurationFromFile 62let getDurationFromFile: VideoMethods.GetDurationFromFile
63let list: VideoMethods.List 63let list: VideoMethods.List
64let listForApi: VideoMethods.ListForApi 64let listForApi: VideoMethods.ListForApi
65let loadByHostAndRemoteId: VideoMethods.LoadByHostAndRemoteId 65let loadByHostAndUUID: VideoMethods.LoadByHostAndUUID
66let listOwnedAndPopulateAuthorAndTags: VideoMethods.ListOwnedAndPopulateAuthorAndTags 66let listOwnedAndPopulateAuthorAndTags: VideoMethods.ListOwnedAndPopulateAuthorAndTags
67let listOwnedByAuthor: VideoMethods.ListOwnedByAuthor 67let listOwnedByAuthor: VideoMethods.ListOwnedByAuthor
68let load: VideoMethods.Load 68let load: VideoMethods.Load
69let loadByUUID: VideoMethods.LoadByUUID
69let loadAndPopulateAuthor: VideoMethods.LoadAndPopulateAuthor 70let loadAndPopulateAuthor: VideoMethods.LoadAndPopulateAuthor
70let loadAndPopulateAuthorAndPodAndTags: VideoMethods.LoadAndPopulateAuthorAndPodAndTags 71let loadAndPopulateAuthorAndPodAndTags: VideoMethods.LoadAndPopulateAuthorAndPodAndTags
72let loadByUUIDAndPopulateAuthorAndPodAndTags: VideoMethods.LoadByUUIDAndPopulateAuthorAndPodAndTags
71let searchAndPopulateAuthorAndPodAndTags: VideoMethods.SearchAndPopulateAuthorAndPodAndTags 73let searchAndPopulateAuthorAndPodAndTags: VideoMethods.SearchAndPopulateAuthorAndPodAndTags
72 74
73export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { 75export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) {
74 Video = sequelize.define<VideoInstance, VideoAttributes>('Video', 76 Video = sequelize.define<VideoInstance, VideoAttributes>('Video',
75 { 77 {
76 id: { 78 uuid: {
77 type: DataTypes.UUID, 79 type: DataTypes.UUID,
78 defaultValue: DataTypes.UUIDV4, 80 defaultValue: DataTypes.UUIDV4,
79 primaryKey: true, 81 allowNull: false,
80 validate: { 82 validate: {
81 isUUID: 4 83 isUUID: 4
82 } 84 }
@@ -95,13 +97,6 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
95 type: DataTypes.ENUM(values(CONSTRAINTS_FIELDS.VIDEOS.EXTNAME)), 97 type: DataTypes.ENUM(values(CONSTRAINTS_FIELDS.VIDEOS.EXTNAME)),
96 allowNull: false 98 allowNull: false
97 }, 99 },
98 remoteId: {
99 type: DataTypes.UUID,
100 allowNull: true,
101 validate: {
102 isUUID: 4
103 }
104 },
105 category: { 100 category: {
106 type: DataTypes.INTEGER, 101 type: DataTypes.INTEGER,
107 allowNull: false, 102 allowNull: false,
@@ -199,6 +194,11 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
199 min: 0, 194 min: 0,
200 isInt: true 195 isInt: true
201 } 196 }
197 },
198 remote: {
199 type: DataTypes.BOOLEAN,
200 allowNull: false,
201 defaultValue: false
202 } 202 }
203 }, 203 },
204 { 204 {
@@ -207,9 +207,6 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
207 fields: [ 'authorId' ] 207 fields: [ 'authorId' ]
208 }, 208 },
209 { 209 {
210 fields: [ 'remoteId' ]
211 },
212 {
213 fields: [ 'name' ] 210 fields: [ 'name' ]
214 }, 211 },
215 { 212 {
@@ -226,6 +223,9 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
226 }, 223 },
227 { 224 {
228 fields: [ 'likes' ] 225 fields: [ 'likes' ]
226 },
227 {
228 fields: [ 'uuid' ]
229 } 229 }
230 ], 230 ],
231 hooks: { 231 hooks: {
@@ -246,9 +246,11 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
246 listOwnedAndPopulateAuthorAndTags, 246 listOwnedAndPopulateAuthorAndTags,
247 listOwnedByAuthor, 247 listOwnedByAuthor,
248 load, 248 load,
249 loadByHostAndRemoteId, 249 loadByUUID,
250 loadByHostAndUUID,
250 loadAndPopulateAuthor, 251 loadAndPopulateAuthor,
251 loadAndPopulateAuthorAndPodAndTags, 252 loadAndPopulateAuthorAndPodAndTags,
253 loadByUUIDAndPopulateAuthorAndPodAndTags,
252 searchAndPopulateAuthorAndPodAndTags, 254 searchAndPopulateAuthorAndPodAndTags,
253 removeFromBlacklist 255 removeFromBlacklist
254 ] 256 ]
@@ -289,8 +291,9 @@ function beforeCreate (video: VideoInstance, options: { transaction: Sequelize.T
289 ) 291 )
290 292
291 if (CONFIG.TRANSCODING.ENABLED === true) { 293 if (CONFIG.TRANSCODING.ENABLED === true) {
294 // Put uuid because we don't have id auto incremented for now
292 const dataInput = { 295 const dataInput = {
293 id: video.id 296 videoUUID: video.uuid
294 } 297 }
295 298
296 tasks.push( 299 tasks.push(
@@ -313,7 +316,7 @@ function afterDestroy (video: VideoInstance) {
313 316
314 if (video.isOwned()) { 317 if (video.isOwned()) {
315 const removeVideoToFriendsParams = { 318 const removeVideoToFriendsParams = {
316 remoteId: video.id 319 uuid: video.uuid
317 } 320 }
318 321
319 tasks.push( 322 tasks.push(
@@ -381,34 +384,27 @@ generateMagnetUri = function (this: VideoInstance) {
381} 384}
382 385
383getVideoFilename = function (this: VideoInstance) { 386getVideoFilename = function (this: VideoInstance) {
384 if (this.isOwned()) return this.id + this.extname 387 return this.uuid + this.extname
385
386 return this.remoteId + this.extname
387} 388}
388 389
389getThumbnailName = function (this: VideoInstance) { 390getThumbnailName = function (this: VideoInstance) {
390 // We always have a copy of the thumbnail 391 // We always have a copy of the thumbnail
391 return this.id + '.jpg' 392 const extension = '.jpg'
393 return this.uuid + extension
392} 394}
393 395
394getPreviewName = function (this: VideoInstance) { 396getPreviewName = function (this: VideoInstance) {
395 const extension = '.jpg' 397 const extension = '.jpg'
396 398 return this.uuid + extension
397 if (this.isOwned()) return this.id + extension
398
399 return this.remoteId + extension
400} 399}
401 400
402getTorrentName = function (this: VideoInstance) { 401getTorrentName = function (this: VideoInstance) {
403 const extension = '.torrent' 402 const extension = '.torrent'
404 403 return this.uuid + extension
405 if (this.isOwned()) return this.id + extension
406
407 return this.remoteId + extension
408} 404}
409 405
410isOwned = function (this: VideoInstance) { 406isOwned = function (this: VideoInstance) {
411 return this.remoteId === null 407 return this.remote === false
412} 408}
413 409
414toFormatedJSON = function (this: VideoInstance) { 410toFormatedJSON = function (this: VideoInstance) {
@@ -435,6 +431,7 @@ toFormatedJSON = function (this: VideoInstance) {
435 431
436 const json = { 432 const json = {
437 id: this.id, 433 id: this.id,
434 uuid: this.uuid,
438 name: this.name, 435 name: this.name,
439 category: this.category, 436 category: this.category,
440 categoryLabel, 437 categoryLabel,
@@ -467,6 +464,7 @@ toAddRemoteJSON = function (this: VideoInstance) {
467 464
468 return readFileBufferPromise(thumbnailPath).then(thumbnailData => { 465 return readFileBufferPromise(thumbnailPath).then(thumbnailData => {
469 const remoteVideo = { 466 const remoteVideo = {
467 uuid: this.uuid,
470 name: this.name, 468 name: this.name,
471 category: this.category, 469 category: this.category,
472 licence: this.licence, 470 licence: this.licence,
@@ -474,7 +472,6 @@ toAddRemoteJSON = function (this: VideoInstance) {
474 nsfw: this.nsfw, 472 nsfw: this.nsfw,
475 description: this.description, 473 description: this.description,
476 infoHash: this.infoHash, 474 infoHash: this.infoHash,
477 remoteId: this.id,
478 author: this.Author.name, 475 author: this.Author.name,
479 duration: this.duration, 476 duration: this.duration,
480 thumbnailData: thumbnailData.toString('binary'), 477 thumbnailData: thumbnailData.toString('binary'),
@@ -493,6 +490,7 @@ toAddRemoteJSON = function (this: VideoInstance) {
493 490
494toUpdateRemoteJSON = function (this: VideoInstance) { 491toUpdateRemoteJSON = function (this: VideoInstance) {
495 const json = { 492 const json = {
493 uuid: this.uuid,
496 name: this.name, 494 name: this.name,
497 category: this.category, 495 category: this.category,
498 licence: this.licence, 496 licence: this.licence,
@@ -500,7 +498,6 @@ toUpdateRemoteJSON = function (this: VideoInstance) {
500 nsfw: this.nsfw, 498 nsfw: this.nsfw,
501 description: this.description, 499 description: this.description,
502 infoHash: this.infoHash, 500 infoHash: this.infoHash,
503 remoteId: this.id,
504 author: this.Author.name, 501 author: this.Author.name,
505 duration: this.duration, 502 duration: this.duration,
506 tags: map<TagInstance, string>(this.Tags, 'name'), 503 tags: map<TagInstance, string>(this.Tags, 'name'),
@@ -615,10 +612,10 @@ listForApi = function (start: number, count: number, sort: string) {
615 }) 612 })
616} 613}
617 614
618loadByHostAndRemoteId = function (fromHost: string, remoteId: string) { 615loadByHostAndUUID = function (fromHost: string, uuid: string) {
619 const query = { 616 const query = {
620 where: { 617 where: {
621 remoteId: remoteId 618 uuid
622 }, 619 },
623 include: [ 620 include: [
624 { 621 {
@@ -640,10 +637,9 @@ loadByHostAndRemoteId = function (fromHost: string, remoteId: string) {
640} 637}
641 638
642listOwnedAndPopulateAuthorAndTags = function () { 639listOwnedAndPopulateAuthorAndTags = function () {
643 // If remoteId is null this is *our* video
644 const query = { 640 const query = {
645 where: { 641 where: {
646 remoteId: null 642 remote: false
647 }, 643 },
648 include: [ Video['sequelize'].models.Author, Video['sequelize'].models.Tag ] 644 include: [ Video['sequelize'].models.Author, Video['sequelize'].models.Tag ]
649 } 645 }
@@ -654,7 +650,7 @@ listOwnedAndPopulateAuthorAndTags = function () {
654listOwnedByAuthor = function (author: string) { 650listOwnedByAuthor = function (author: string) {
655 const query = { 651 const query = {
656 where: { 652 where: {
657 remoteId: null 653 remote: false
658 }, 654 },
659 include: [ 655 include: [
660 { 656 {
@@ -669,11 +665,20 @@ listOwnedByAuthor = function (author: string) {
669 return Video.findAll(query) 665 return Video.findAll(query)
670} 666}
671 667
672load = function (id: string) { 668load = function (id: number) {
673 return Video.findById(id) 669 return Video.findById(id)
674} 670}
675 671
676loadAndPopulateAuthor = function (id: string) { 672loadByUUID = function (uuid: string) {
673 const query = {
674 where: {
675 uuid
676 }
677 }
678 return Video.findOne(query)
679}
680
681loadAndPopulateAuthor = function (id: number) {
677 const options = { 682 const options = {
678 include: [ Video['sequelize'].models.Author ] 683 include: [ Video['sequelize'].models.Author ]
679 } 684 }
@@ -681,7 +686,7 @@ loadAndPopulateAuthor = function (id: string) {
681 return Video.findById(id, options) 686 return Video.findById(id, options)
682} 687}
683 688
684loadAndPopulateAuthorAndPodAndTags = function (id: string) { 689loadAndPopulateAuthorAndPodAndTags = function (id: number) {
685 const options = { 690 const options = {
686 include: [ 691 include: [
687 { 692 {
@@ -695,6 +700,23 @@ loadAndPopulateAuthorAndPodAndTags = function (id: string) {
695 return Video.findById(id, options) 700 return Video.findById(id, options)
696} 701}
697 702
703loadByUUIDAndPopulateAuthorAndPodAndTags = function (uuid: string) {
704 const options = {
705 where: {
706 uuid
707 },
708 include: [
709 {
710 model: Video['sequelize'].models.Author,
711 include: [ { model: Video['sequelize'].models.Pod, required: false } ]
712 },
713 Video['sequelize'].models.Tag
714 ]
715 }
716
717 return Video.findOne(options)
718}
719
698searchAndPopulateAuthorAndPodAndTags = function (value: string, field: string, start: number, count: number, sort: string) { 720searchAndPopulateAuthorAndPodAndTags = function (value: string, field: string, start: number, count: number, sort: string) {
699 const podInclude: Sequelize.IncludeOptions = { 721 const podInclude: Sequelize.IncludeOptions = {
700 model: Video['sequelize'].models.Pod, 722 model: Video['sequelize'].models.Pod,