]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/models/tag.js
Client: upgrade angular dep'
[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 timestamps: false,
15 indexes: [
16 {
17 fields: [ 'name' ],
18 unique: true
19 }
20 ],
21 classMethods: {
22 associate
23 }
24 }
25 )
26
27 return Tag
28 }
29
30 // ---------------------------------------------------------------------------
31
32 function associate (models) {
33 this.belongsToMany(models.Video, {
34 foreignKey: 'tagId',
35 through: models.VideoTag,
36 onDelete: 'cascade'
37 })
38 }