Built motion from commit d415888.|0.0.73
[motion.git] / server / models / sugarcrm_account.js
1 'use strict';
2
3 module.exports = function(sequelize, DataTypes) {
4   return sequelize.define('SugarcrmAccount', {
5     name: DataTypes.STRING,
6     description: DataTypes.STRING,
7     username: {
8       type: DataTypes.STRING
9     },
10     remoteUri: DataTypes.STRING,
11     password: DataTypes.STRING
12   }, {
13     tableName: 'sugarcrm_accounts',
14     associate: function(models) {
15       models.SugarcrmAccount.hasMany(models.SugarcrmConfiguration, {
16         as: 'Configurations',
17         foreignKey: 'AccountId'
18       });
19       models.SugarcrmAccount.addScope('configurations', {
20         include: [{
21           model: models.SugarcrmConfiguration,
22           as: 'Configurations',
23           required: false,
24           attributes: ['id', 'name']
25         }]
26       });
27     }
28   });
29 };