summaryrefslogtreecommitdiffstats
path: root/server/models
diff options
context:
space:
mode:
authorJannik Schönartz2018-08-06 03:04:54 +0200
committerJannik Schönartz2018-08-06 03:04:54 +0200
commit311a686f3672a00c8def9190c874d6f83a006e35 (patch)
tree29d05513d8c1e96dca50aae4445845177bbf5d3f /server/models
parent[webapp/searchtable] bugfix (diff)
downloadbas-311a686f3672a00c8def9190c874d6f83a006e35.tar.gz
bas-311a686f3672a00c8def9190c874d6f83a006e35.tar.xz
bas-311a686f3672a00c8def9190c874d6f83a006e35.zip
[server/external-backends] Implemented import Objects from iDoIT
renamed external-backends.js in index.js so its return when requireing the folder Added new tables for the external id mapping for clients / groups iDoIT method for importing Objects and adding them in the db with all neccessary constraints
Diffstat (limited to 'server/models')
-rw-r--r--server/models/backend.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/server/models/backend.js b/server/models/backend.js
index 62b936a..f08e6c0 100644
--- a/server/models/backend.js
+++ b/server/models/backend.js
@@ -14,12 +14,12 @@ module.exports = (sequelize, DataTypes) => {
type: DataTypes.STRING(2048),
defaultValue: '[]'
},
- groups: {
+ groupTypes: {
allowNull: false,
type: DataTypes.STRING(4096),
defaultValue: '[]'
},
- clients: {
+ clientTypes: {
allowNull: false,
type: DataTypes.STRING(4096),
defaultValue: '[]'
@@ -31,7 +31,11 @@ module.exports = (sequelize, DataTypes) => {
timestamps: false
})
backend.associate = function (models) {
- // associations can be defined here
+ var BackendXGroup = sequelize.define('backend_x_group', { externalId: DataTypes.INTEGER, externalType: DataTypes.STRING }, { timestamps: false, freezeTableName: true })
+ var BackendXClient = sequelize.define('backend_x_client', { externalId: DataTypes.INTEGER, externalType: DataTypes.STRING }, { timestamps: false, freezeTableName: true })
+
+ backend.belongsToMany(models.group, { as: 'mappedGroups', through: BackendXGroup, foreignKey: 'backendId', otherKey: 'groupId' })
+ backend.belongsToMany(models.client, { as: 'mappedClients', through: BackendXClient, foreignKey: 'backendId', otherKey: 'clientId' })
}
return backend
}