]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/models/tag.js
d6c2d3bb12ff2c75a7a489951d2d97411ecb0af5
[github/Chocobozzz/PeerTube.git] / server / models / tag.js
1 'use strict'
2
3 // ---------------------------------------------------------------------------
4
5 module.exports = function (sequelize, DataTypes) {
6 const Tag = sequelize.define('Tag',
7 {
8 name: {
9 type: DataTypes.STRING,
10 allowNull: false
11 }
12 },
13 {
14 classMethods: {
15 associate
16 }
17 }
18 )
19
20 return Tag
21 }
22
23 // ---------------------------------------------------------------------------
24
25 function associate (models) {
26 this.belongsToMany(models.Video, {
27 foreignKey: 'tagId',
28 through: models.VideoTag,
29 onDelete: 'cascade'
30 })
31 }