Built motion from commit 0010de3.|0.0.91
[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       // Tag.belongsToMany(models.Contact, {
30       //   through: 'contact_tags'
31       // });
32     }
33   });
34
35   return Tag;
36 };