From d846501818c2d29e66e6fd141789cb04fd55a437 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 15 Nov 2017 17:56:21 +0100 Subject: Handle announces in inbox --- server/models/video/video-share.ts | 49 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 server/models/video/video-share.ts (limited to 'server/models/video/video-share.ts') diff --git a/server/models/video/video-share.ts b/server/models/video/video-share.ts new file mode 100644 index 000000000..358491fd2 --- /dev/null +++ b/server/models/video/video-share.ts @@ -0,0 +1,49 @@ +import * as Sequelize from 'sequelize' + +import { addMethodsToModel } from '../utils' +import { VideoShareAttributes, VideoShareInstance } from './video-share-interface' + +let VideoShare: Sequelize.Model + +export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { + VideoShare = sequelize.define('VideoShare', + { }, + { + indexes: [ + { + fields: [ 'accountId' ] + }, + { + fields: [ 'videoId' ] + } + ] + } + ) + + const classMethods = [ + associate + ] + addMethodsToModel(VideoShare, classMethods) + + return VideoShare +} + +// ------------------------------ METHODS ------------------------------ + +function associate (models) { + VideoShare.belongsTo(models.Account, { + foreignKey: { + name: 'accountId', + allowNull: false + }, + onDelete: 'cascade' + }) + + VideoShare.belongsTo(models.Video, { + foreignKey: { + name: 'videoId', + allowNull: true + }, + onDelete: 'cascade' + }) +} -- cgit v1.2.3