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