diff options
Diffstat (limited to 'server/models/video/video-channel-share.ts')
-rw-r--r-- | server/models/video/video-channel-share.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/server/models/video/video-channel-share.ts b/server/models/video/video-channel-share.ts index 01f84c806..e47c0dae7 100644 --- a/server/models/video/video-channel-share.ts +++ b/server/models/video/video-channel-share.ts | |||
@@ -5,6 +5,7 @@ import { VideoChannelShareAttributes, VideoChannelShareInstance, VideoChannelSha | |||
5 | 5 | ||
6 | let VideoChannelShare: Sequelize.Model<VideoChannelShareInstance, VideoChannelShareAttributes> | 6 | let VideoChannelShare: Sequelize.Model<VideoChannelShareInstance, VideoChannelShareAttributes> |
7 | let loadAccountsByShare: VideoChannelShareMethods.LoadAccountsByShare | 7 | let loadAccountsByShare: VideoChannelShareMethods.LoadAccountsByShare |
8 | let load: VideoChannelShareMethods.Load | ||
8 | 9 | ||
9 | export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { | 10 | export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { |
10 | VideoChannelShare = sequelize.define<VideoChannelShareInstance, VideoChannelShareAttributes>('VideoChannelShare', | 11 | VideoChannelShare = sequelize.define<VideoChannelShareInstance, VideoChannelShareAttributes>('VideoChannelShare', |
@@ -23,6 +24,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
23 | 24 | ||
24 | const classMethods = [ | 25 | const classMethods = [ |
25 | associate, | 26 | associate, |
27 | load, | ||
26 | loadAccountsByShare | 28 | loadAccountsByShare |
27 | ] | 29 | ] |
28 | addMethodsToModel(VideoChannelShare, classMethods) | 30 | addMethodsToModel(VideoChannelShare, classMethods) |
@@ -50,6 +52,19 @@ function associate (models) { | |||
50 | }) | 52 | }) |
51 | } | 53 | } |
52 | 54 | ||
55 | load = function (accountId: number, videoChannelId: number) { | ||
56 | return VideoChannelShare.findOne({ | ||
57 | where: { | ||
58 | accountId, | ||
59 | videoChannelId | ||
60 | }, | ||
61 | include: [ | ||
62 | VideoChannelShare['sequelize'].models.Account, | ||
63 | VideoChannelShare['sequelize'].models.VideoChannel | ||
64 | ] | ||
65 | }) | ||
66 | } | ||
67 | |||
53 | loadAccountsByShare = function (videoChannelId: number) { | 68 | loadAccountsByShare = function (videoChannelId: number) { |
54 | const query = { | 69 | const query = { |
55 | where: { | 70 | where: { |