1 import * as Sequelize from 'sequelize'
3 import { addMethodsToModel } from '../utils'
4 import { VideoChannelShareAttributes, VideoChannelShareInstance, VideoChannelShareMethods } from './video-channel-share-interface'
6 let VideoChannelShare: Sequelize.Model<VideoChannelShareInstance, VideoChannelShareAttributes>
7 let loadAccountsByShare: VideoChannelShareMethods.LoadAccountsByShare
9 export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) {
10 VideoChannelShare = sequelize.define<VideoChannelShareInstance, VideoChannelShareAttributes>('VideoChannelShare',
15 fields: [ 'accountId' ]
18 fields: [ 'videoChannelId' ]
24 const classMethods = [
28 addMethodsToModel(VideoChannelShare, classMethods)
30 return VideoChannelShare
33 // ------------------------------ METHODS ------------------------------
35 function associate (models) {
36 VideoChannelShare.belongsTo(models.Account, {
44 VideoChannelShare.belongsTo(models.VideoChannel, {
46 name: 'videoChannelId',
53 loadAccountsByShare = function (videoChannelId: number) {
60 model: VideoChannelShare['sequelize'].models.Account,
66 return VideoChannelShare.findAll(query)
67 .then(res => res.map(r => r.Account))