]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/models/tag.js
Server: add database field validations
[github/Chocobozzz/PeerTube.git] / server / models / tag.js
... / ...
CommitLineData
1'use strict'
2
3// ---------------------------------------------------------------------------
4
5module.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
25function associate (models) {
26 this.belongsToMany(models.Video, {
27 foreignKey: 'tagId',
28 through: models.VideoTag,
29 onDelete: 'cascade'
30 })
31}