PeerTube/server/models/tag.js

32 lines
589 B
JavaScript
Raw Normal View History

2016-12-24 16:59:17 +01:00
'use strict'
// ---------------------------------------------------------------------------
module.exports = function (sequelize, DataTypes) {
const Tag = sequelize.define('Tag',
{
name: {
2016-12-28 15:49:23 +01:00
type: DataTypes.STRING,
allowNull: false
2016-12-24 16:59:17 +01:00
}
},
{
classMethods: {
associate
}
}
)
return Tag
}
// ---------------------------------------------------------------------------
function associate (models) {
this.belongsToMany(models.Video, {
foreignKey: 'tagId',
through: models.VideoTag,
onDelete: 'cascade'
})
}