diff --git a/packages/api/src/controllers/databaseConnections.js b/packages/api/src/controllers/databaseConnections.js index de947e74..23820468 100644 --- a/packages/api/src/controllers/databaseConnections.js +++ b/packages/api/src/controllers/databaseConnections.js @@ -31,6 +31,7 @@ const { testConnectionPermission } = require('../utility/hasPermission'); const { MissingCredentialsError } = require('../utility/exceptions'); const pipeForkLogs = require('../utility/pipeForkLogs'); const crypto = require('crypto'); +const loadModelTransform = require('../utility/loadModelTransform'); const logger = getLogger('databaseConnections'); @@ -392,11 +393,12 @@ module.exports = { }, structure_meta: true, - async structure({ conid, database }, req) { + async structure({ conid, database, modelTransFile }, req) { testConnectionPermission(conid, req); if (conid == '__model') { const model = await importDbModel(database); - return model; + const trans = await loadModelTransform(modelTransFile); + return trans ? trans(model) : model; } const opened = await this.ensureOpened(conid, database); diff --git a/packages/web/src/utility/metadataLoaders.ts b/packages/web/src/utility/metadataLoaders.ts index 7528ff47..9d7abe9a 100644 --- a/packages/web/src/utility/metadataLoaders.ts +++ b/packages/web/src/utility/metadataLoaders.ts @@ -6,9 +6,9 @@ import { extendDatabaseInfo } from 'dbgate-tools'; import { setLocalStorage } from '../utility/storageCache'; import { apiCall, apiOff, apiOn } from './api'; -const databaseInfoLoader = ({ conid, database }) => ({ +const databaseInfoLoader = ({ conid, database, modelTransFile }) => ({ url: 'database-connections/structure', - params: { conid, database }, + params: { conid, database, modelTransFile }, reloadTrigger: { key: `database-structure-changed`, conid, database }, transform: extendDatabaseInfo, });