mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-21 16:26:00 +00:00
introduced yarn workspace
This commit is contained in:
22
packages/api/src/controllers/tables.js
Normal file
22
packages/api/src/controllers/tables.js
Normal file
@@ -0,0 +1,22 @@
|
||||
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),
|
||||
};
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user