3 module.exports = function(sequelize, DataTypes) {
4 var SmsRoom = sequelize.define('SmsRoom', {
6 type: DataTypes.STRING,
12 type: DataTypes.ENUM('NEW', 'OPEN', 'CLOSED', 'UNMANAGED'),
19 if (this.getDataValue('tags')) {
20 tags = this.getDataValue('tags').split(';');
28 this.setDataValue('tags', val && val.length ? val.join(';') + ';' : null);
32 type: DataTypes.STRING
35 tableName: 'sms_rooms',
36 associate: function(models) {
38 SmsRoom.hasMany(models.SmsMessage);
39 SmsRoom.belongsToMany(models.User, {
40 through: 'user_has_sms_rooms'
42 SmsRoom.belongsTo(models.SmsAccount);
43 SmsRoom.addScope('default', {
48 model: models.SmsAccount
50 model: models.SmsMessage,
53 attributes: ['id', 'name', 'fullname', 'email']
57 attributes: ['id', 'name', 'fullname', 'email']
60 SmsRoom.addScope('agent', function(id) {