PeerTube/server/models/tag.js

31 lines
563 B
JavaScript
Raw Normal View History

2016-12-24 09:59:17 -06:00
'use strict'
// ---------------------------------------------------------------------------
module.exports = function (sequelize, DataTypes) {
const Tag = sequelize.define('Tag',
{
name: {
type: DataTypes.STRING
}
},
{
classMethods: {
associate
}
}
)
return Tag
}
// ---------------------------------------------------------------------------
function associate (models) {
this.belongsToMany(models.Video, {
foreignKey: 'tagId',
through: models.VideoTag,
onDelete: 'cascade'
})
}