]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/models/video/video-channel-share.ts
Server shares user videos
[github/Chocobozzz/PeerTube.git] / server / models / video / video-channel-share.ts
CommitLineData
d8465018
C
1import * as Sequelize from 'sequelize'
2
3import { addMethodsToModel } from '../utils'
4import { VideoChannelShareAttributes, VideoChannelShareInstance } from './video-channel-share-interface'
5
6let VideoChannelShare: Sequelize.Model<VideoChannelShareInstance, VideoChannelShareAttributes>
7
8export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) {
9 VideoChannelShare = sequelize.define<VideoChannelShareInstance, VideoChannelShareAttributes>('VideoChannelShare',
10 { },
11 {
12 indexes: [
13 {
14 fields: [ 'accountId' ]
15 },
16 {
17 fields: [ 'videoChannelId' ]
18 }
19 ]
20 }
21 )
22
23 const classMethods = [
24 associate
25 ]
26 addMethodsToModel(VideoChannelShare, classMethods)
27
28 return VideoChannelShare
29}
30
31// ------------------------------ METHODS ------------------------------
32
33function associate (models) {
34 VideoChannelShare.belongsTo(models.Account, {
35 foreignKey: {
36 name: 'accountId',
37 allowNull: false
38 },
39 onDelete: 'cascade'
40 })
41
42 VideoChannelShare.belongsTo(models.VideoChannel, {
43 foreignKey: {
44 name: 'videoChannelId',
45 allowNull: true
46 },
47 onDelete: 'cascade'
48 })
49}