mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 18:56:00 +00:00
23 lines
937 B
JavaScript
23 lines
937 B
JavaScript
const _ = require('lodash');
|
|
const databaseConnections = require('./databaseConnections');
|
|
|
|
module.exports = {
|
|
// tableData_meta: 'get',
|
|
// async tableData({ conid, database, schemaName, pureName }) {
|
|
// const opened = await databaseConnections.ensureOpened(conid, database);
|
|
// const res = await databaseConnections.sendRequest(opened, { msgtype: 'tableData', schemaName, pureName });
|
|
// return res;
|
|
// },
|
|
|
|
tableInfo_meta: 'get',
|
|
async tableInfo({ conid, database, schemaName, pureName }) {
|
|
const opened = await databaseConnections.ensureOpened(conid, database);
|
|
const table = opened.structure.tables.find(x => x.pureName == pureName && x.schemaName == schemaName);
|
|
const allForeignKeys = _.flatten(opened.structure.tables.map(x => x.foreignKeys));
|
|
return {
|
|
...table,
|
|
dependencies: allForeignKeys.filter(x => x.refSchemaName == schemaName && x.refTableName == pureName),
|
|
};
|
|
},
|
|
};
|