1 import * as Sequelize from 'sequelize'
2 import { BelongsTo, Column, CreatedAt, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript'
3 import { AccountModel } from '../account/account'
4 import { VideoChannelModel } from './video-channel'
7 tableName: 'videoChannelShare',
10 fields: [ 'accountId' ]
13 fields: [ 'videoChannelId' ]
17 export class VideoChannelShareModel extends Model<VideoChannelShareModel> {
24 @ForeignKey(() => AccountModel)
28 @BelongsTo(() => AccountModel, {
36 @ForeignKey(() => VideoChannelModel)
38 videoChannelId: number
40 @BelongsTo(() => VideoChannelModel, {
46 VideoChannel: VideoChannelModel
48 static load (accountId: number, videoChannelId: number, t: Sequelize.Transaction) {
49 return VideoChannelShareModel.findOne({
62 static loadAccountsByShare (videoChannelId: number, t: Sequelize.Transaction) {
76 return VideoChannelShareModel.findAll(query)
77 .then(res => res.map(r => r.Account))