5 module.exports = function(sequelize, DataTypes) {
7 var Trigger = sequelize.define('Trigger', {
8 name: DataTypes.STRING,
9 channel: DataTypes.STRING,
10 description: DataTypes.STRING,
12 type: DataTypes.BOOLEAN,
16 tableName: 'triggers',
17 associate: function(models) {
18 Trigger.hasMany(models.ToolsCondition, {
23 foreignKey: 'TriggerAllId',
27 Trigger.hasMany(models.ToolsCondition, {
32 foreignKey: 'TriggerAnyId',
36 Trigger.hasMany(models.ToolsAction, {
41 Trigger.addScope('all', {
43 model: models.ToolsCondition,
45 attributes: ['field', 'operator', 'value']
47 model: models.ToolsCondition,
49 attributes: ['field', 'operator', 'value']
51 model: models.ToolsAction,
53 attributes: ['action', 'data1', 'data2', 'data3', 'data4', 'data5']