summaryrefslogtreecommitdiffstats
path: root/server/models/group.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/group.js')
-rw-r--r--server/models/group.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/server/models/group.js b/server/models/group.js
index 9151db5..62a5665 100644
--- a/server/models/group.js
+++ b/server/models/group.js
@@ -7,13 +7,17 @@ module.exports = (sequelize, DataTypes) => {
primaryKey: true,
type: DataTypes.INTEGER
},
- name: DataTypes.STRING
+ name: DataTypes.STRING,
+ description: DataTypes.STRING(2048)
}, {
timestamps: false
})
- var GroupXGroup = sequelize.define('group_x_group', {}, { timestamps: false, freezeTableName: true })
group.associate = function (models) {
- group.belongsToMany(group, { as: 'parents', through: GroupXGroup, foreignKey: 'childId', otherKey: 'parentId'})
+ var GroupXGroup = sequelize.define('group_x_group', {}, { timestamps: false, freezeTableName: true })
+ var GroupXClient = sequelize.define('group_x_client', {}, { timestamps: false, freezeTableName: true })
+ group.belongsToMany(group, { as: 'parents', through: GroupXGroup, foreignKey: 'childId', otherKey: 'parentId' })
+ group.belongsToMany(group, { as: 'subgroups', through: GroupXGroup, foreignKey: 'parentId', otherKey: 'childId' })
+ group.belongsToMany(models.client, { as: 'clients', through: GroupXClient, foreignKey: 'groupId', otherKey: 'clientId' })
}
return group
}