Built motion from commit d415888.|0.0.73
[motion.git] / server / models / tag.js
1 /**
2  * tag Model
3  */
4
5 module.exports = function(sequelize, DataTypes) {
6
7   var Tag = sequelize.define('Tag', {
8     name: {
9       type: DataTypes.STRING,
10       unique: true,
11       allowNull: false,
12       validate: {
13         notEmpty: true,
14       }
15     },
16     description: DataTypes.STRING
17   }, {
18     tableName: 'tags',
19     associate: function(models) {
20       Tag.belongsToMany(models.ZendeskConfiguration, {
21         through: 'zendesk_configuration_has_tags'
22       });
23       Tag.addScope('configuration', {
24         include: [{
25           all: true
26         }]
27       });
28       // Tag.belongsToMany(models.Contact, {
29       //   through: 'contact_tags'
30       // });
31     }
32   });
33
34   return Tag;
35 };