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