aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-share.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video-share.ts')
-rw-r--r--server/models/video/video-share.ts16
1 files changed, 15 insertions, 1 deletions
diff --git a/server/models/video/video-share.ts b/server/models/video/video-share.ts
index 22ac31a4a..fe5d56d42 100644
--- a/server/models/video/video-share.ts
+++ b/server/models/video/video-share.ts
@@ -5,6 +5,7 @@ import { VideoShareAttributes, VideoShareInstance, VideoShareMethods } from './v
5 5
6let VideoShare: Sequelize.Model<VideoShareInstance, VideoShareAttributes> 6let VideoShare: Sequelize.Model<VideoShareInstance, VideoShareAttributes>
7let loadAccountsByShare: VideoShareMethods.LoadAccountsByShare 7let loadAccountsByShare: VideoShareMethods.LoadAccountsByShare
8let load: VideoShareMethods.Load
8 9
9export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { 10export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) {
10 VideoShare = sequelize.define<VideoShareInstance, VideoShareAttributes>('VideoShare', 11 VideoShare = sequelize.define<VideoShareInstance, VideoShareAttributes>('VideoShare',
@@ -23,7 +24,8 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
23 24
24 const classMethods = [ 25 const classMethods = [
25 associate, 26 associate,
26 loadAccountsByShare 27 loadAccountsByShare,
28 load
27 ] 29 ]
28 addMethodsToModel(VideoShare, classMethods) 30 addMethodsToModel(VideoShare, classMethods)
29 31
@@ -50,6 +52,18 @@ function associate (models) {
50 }) 52 })
51} 53}
52 54
55load = function (accountId: number, videoId: number) {
56 return VideoShare.findOne({
57 where: {
58 accountId,
59 videoId
60 },
61 include: [
62 VideoShare['sequelize'].models.Account
63 ]
64 })
65}
66
53loadAccountsByShare = function (videoId: number) { 67loadAccountsByShare = function (videoId: number) {
54 const query = { 68 const query = {
55 where: { 69 where: {