From 20932daf5ab54721118726d78340e78d0793cbe3 Mon Sep 17 00:00:00 2001 From: Udo Walter Date: Mon, 17 Sep 2018 21:34:40 +0000 Subject: add ipxe config relation to groups and clients --- server/models/client.js | 1 + server/models/config.js | 2 ++ server/models/group.js | 1 + 3 files changed, 4 insertions(+) (limited to 'server/models') diff --git a/server/models/client.js b/server/models/client.js index 5789788..c279cfc 100644 --- a/server/models/client.js +++ b/server/models/client.js @@ -18,6 +18,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.belongsTo(models.config) } return client } diff --git a/server/models/config.js b/server/models/config.js index 11661fd..aee8892 100644 --- a/server/models/config.js +++ b/server/models/config.js @@ -22,6 +22,8 @@ module.exports = (sequelize, DataTypes) => { keyBind: DataTypes.STRING }, { timestamps: false, freezeTableName: true }) config.belongsToMany(models.entry, { as: 'entries', through: ConfigXEntry, foreignKey: 'configId', otherKey: 'entryId' }) + config.hasMany(models.group) + config.hasMany(models.client) } return config } diff --git a/server/models/group.js b/server/models/group.js index 62a5665..472ecf2 100644 --- a/server/models/group.js +++ b/server/models/group.js @@ -18,6 +18,7 @@ module.exports = (sequelize, DataTypes) => { 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' }) + group.belongsTo(models.config) } return group } -- cgit v1.2.3-55-g7522