From faf1188d03e1302dd615a118bce73dd6197be8f1 Mon Sep 17 00:00:00 2001 From: Udo Walter Date: Wed, 1 Aug 2018 20:17:33 +0000 Subject: [groups] add edit functionality to group infos --- server/models/client.js | 4 ++-- server/models/group.js | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'server/models') diff --git a/server/models/client.js b/server/models/client.js index 483d1e6..5789788 100644 --- a/server/models/client.js +++ b/server/models/client.js @@ -8,7 +8,7 @@ module.exports = (sequelize, DataTypes) => { type: DataTypes.INTEGER }, name: DataTypes.STRING, - description: DataTypes.STRING, + description: DataTypes.STRING(2048), ip: DataTypes.STRING, mac: DataTypes.STRING, uuid: DataTypes.STRING @@ -17,7 +17,7 @@ module.exports = (sequelize, DataTypes) => { }) client.associate = function (models) { var GroupXClient = sequelize.define('group_x_client', {}, { timestamps: false, freezeTableName: true }) - client.belongsToMany(models.group, { as: 'groups', through: GroupXClient, foreignKey: 'clientId', otherKey: 'groupId'}) + client.belongsToMany(models.group, { as: 'groups', through: GroupXClient, foreignKey: 'clientId', otherKey: 'groupId' }) } return client } diff --git a/server/models/group.js b/server/models/group.js index e988497..62a5665 100644 --- a/server/models/group.js +++ b/server/models/group.js @@ -8,13 +8,16 @@ module.exports = (sequelize, DataTypes) => { type: DataTypes.INTEGER }, name: DataTypes.STRING, - description: DataTypes.STRING + description: DataTypes.STRING(2048) }, { timestamps: false }) group.associate = function (models) { var GroupXGroup = sequelize.define('group_x_group', {}, { timestamps: false, freezeTableName: true }) - group.belongsToMany(group, { as: 'parents', through: GroupXGroup, foreignKey: 'childId', otherKey: 'parentId'}) + 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 } -- cgit v1.2.3-55-g7522