Built motion from commit d127c62.|0.0.151
[motion.git] / server / models / int_freshdesk_configuration.js
1 'use strict';
2
3 module.exports = function(sequelize, DataTypes) {
4   return sequelize.define('FreshdeskConfiguration', {
5     name: DataTypes.STRING,
6     description: DataTypes.STRING
7   }, {
8     tableName: 'int_freshdesk_configurations',
9     associate: function(models) {
10       models.FreshdeskConfiguration.belongsTo(models.FreshdeskAccount, {
11         foreignKey: 'AccountId'
12       });
13       models.FreshdeskConfiguration.hasMany(models.FreshdeskField, {
14         as: 'Subject',
15         foreignKey: 'SubjectId'
16       });
17       models.FreshdeskConfiguration.hasMany(models.FreshdeskField, {
18         as: 'Description',
19         foreignKey: 'DescriptionId'
20       });
21       models.FreshdeskConfiguration.hasMany(models.FreshdeskField, {
22         as: 'Field',
23         foreignKey: 'FieldId'
24       });
25       models.FreshdeskConfiguration.belongsToMany(models.Tag, {
26         through: 'int_freshdesk_configuration_has_tags'
27       });
28       models.FreshdeskConfiguration.addScope('account', function(AccountId) {
29         return {
30           where: {
31             AccountId: AccountId
32           },
33           include: [{
34             all: true
35           }]
36         }
37       });
38     }
39   });
40 };