Move tags in another table
[oweals/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       }
11     },
12     {
13       classMethods: {
14         associate
15       }
16     }
17   )
18
19   return Tag
20 }
21
22 // ---------------------------------------------------------------------------
23
24 function associate (models) {
25   this.belongsToMany(models.Video, {
26     foreignKey: 'tagId',
27     through: models.VideoTag,
28     onDelete: 'cascade'
29   })
30 }