Built motion from commit ab2cbc7.|0.0.98
[motion.git] / server / models / tools_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         is: /^[A-Za-z0-9]+$/i
15       }
16     },
17     description: DataTypes.STRING
18   }, {
19     tableName: 'tools_tags',
20     associate: function(models) {
21       Tag.belongsToMany(models.ZendeskConfiguration, {
22         through: 'zendesk_configuration_has_tags'
23       });
24       Tag.addScope('configuration', {
25         include: [{
26           all: true
27         }]
28       });
29     }
30   });
31
32   return Tag;
33 };