ms sql analyser class, typescript check

This commit is contained in:
Jan Prochazka
2020-01-06 22:33:20 +01:00
parent b31bf2b5d0
commit c886846268
11 changed files with 80 additions and 2 deletions

View File

@@ -1,5 +1,8 @@
// @ts-check
const path = require('path');
const { fork } = require('child_process');
// @ts-ignore
const _ = require('lodash');
const nedb = require('nedb-promises');
@@ -12,6 +15,7 @@ module.exports = {
async _init() {
const dir = await datadir();
// @ts-ignore
this.datastore = nedb.create(path.join(dir, 'connections.jsonl'));
},

View File

@@ -0,0 +1,15 @@
// @ts-check
class DatabaseAnalyser {
/**
*
* @param {import('../default/types').EngineDriver} driver
*/
constructor(pool, driver) {
this.pool = pool;
this.driver = driver;
}
runAnalysis() {}
}
module.exports = DatabaseAnalyser;

View File

@@ -0,0 +1,8 @@
export interface EngineDriver {
connect({ server, port, user, password });
query(pool, sql: string): [];
getVersion(pool): string;
listDatabases(pool): [{ name: string }];
analyseFull(pool);
analyseIncremental(pool);
}

View File

@@ -0,0 +1,22 @@
// @ts-check
const fs = require('fs-extra');
const path = require('path');
const DatabaseAnalayser = require('../default/DatabaseAnalyser');
async function loadQuery(name) {
return await fs.readFile(path.join(__dirname, name), 'utf-8');
}
class MsSqlAnalyser extends DatabaseAnalayser {
constructor(pool, driver) {
super(pool, driver);
}
async runAnalysis() {
const tables = this.driver.query(this.pool, await loadQuery('tables.sql'));
}
}
module.exports = MsSqlAnalyser;

View File

@@ -17,4 +17,10 @@ module.exports = {
const res = await this.query(pool, 'SELECT name FROM sys.databases order by name');
return res;
},
async analyseFull(pool) {
},
async analyseIncremental(pool) {
},
};

View File

@@ -0,0 +1,6 @@
select
o.name as tableName, s.name as schemaName, o.objectId,
o.createDate, o.modifyDate
from sys.tables o
inner join sys.schemas s on o.schema_id = s.schema_id
where o.object_id =[OBJECT_ID_CONDITION]

View File

@@ -1,3 +1,5 @@
// @ts-check
const os = require('os');
const path = require('path');
const fs = require('fs-extra');

View File

@@ -1,3 +1,5 @@
// @ts-check
let socket = null;
module.exports = {

View File

@@ -1,6 +1,12 @@
// @ts-check
// @ts-ignore
const _ = require('lodash');
const express = require('express');
/**
* @param {string} route
*/
module.exports = function useController(app, route, controller) {
const router = express.Router();