mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 04:00:59 +00:00
model transform
This commit is contained in:
parent
4927c13e55
commit
967587c8e4
@ -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);
|
||||
|
@ -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,
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user