ms sql analyse - table list

This commit is contained in:
Jan Prochazka
2020-01-19 21:01:48 +01:00
parent c819aac098
commit 69322a4e41
14 changed files with 209 additions and 51 deletions

View File

@@ -0,0 +1,37 @@
const engines = require('../engines');
let systemConnection;
let storedConnection;
async function handleFullRefresh() {
const driver = engines(storedConnection);
const structure = await driver.analyseFull(systemConnection);
console.log('SENDING STRUCTURE', structure);
process.send({ msgtype: 'structure', structure });
}
async function handleConnect(connection, database) {
storedConnection = connection;
const driver = engines(storedConnection);
systemConnection = await driver.connect({ ...storedConnection, database });
handleFullRefresh();
setInterval(handleFullRefresh, 30 * 1000);
}
const messageHandlers = {
connect: handleConnect,
};
async function handleMessage({ msgtype, database, ...other }) {
const handler = messageHandlers[msgtype];
await handler(other, database);
}
process.on('message', async message => {
try {
await handleMessage(message);
} catch (e) {
process.send({ msgtype: 'error', error: e.message });
}
});