mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-17 22:36:01 +00:00
ms sql analyser class, typescript check
This commit is contained in:
@@ -18,9 +18,11 @@
|
||||
"socket.io": "^2.3.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "nodemon src/index.js"
|
||||
"start": "nodemon src/index.js",
|
||||
"tscheck": "tsc --allowJs --noEmit src/index.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodemon": "^2.0.2"
|
||||
"nodemon": "^2.0.2",
|
||||
"typescript": "^3.7.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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'));
|
||||
},
|
||||
|
||||
|
||||
15
api/src/engines/default/DatabaseAnalyser.js
Normal file
15
api/src/engines/default/DatabaseAnalyser.js
Normal 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;
|
||||
8
api/src/engines/default/types.ts
Normal file
8
api/src/engines/default/types.ts
Normal 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);
|
||||
}
|
||||
22
api/src/engines/mssql/MsSqlAnalyser.js
Normal file
22
api/src/engines/mssql/MsSqlAnalyser.js
Normal 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;
|
||||
@@ -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) {
|
||||
|
||||
},
|
||||
};
|
||||
|
||||
6
api/src/engines/mssql/tables.sql
Normal file
6
api/src/engines/mssql/tables.sql
Normal 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]
|
||||
@@ -1,3 +1,5 @@
|
||||
// @ts-check
|
||||
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const fs = require('fs-extra');
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// @ts-check
|
||||
|
||||
let socket = null;
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -2561,6 +2561,11 @@ type-is@~1.6.17, type-is@~1.6.18:
|
||||
media-typer "0.3.0"
|
||||
mime-types "~2.1.24"
|
||||
|
||||
typescript@^3.7.4:
|
||||
version "3.7.4"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.4.tgz#1743a5ec5fef6a1fa9f3e4708e33c81c73876c19"
|
||||
integrity sha512-A25xv5XCtarLwXpcDNZzCGvW2D1S3/bACratYBx2sax8PefsFhlYmkQicKHvpYflFS8if4zne5zT5kpJ7pzuvw==
|
||||
|
||||
undefsafe@^2.0.2:
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/undefsafe/-/undefsafe-2.0.2.tgz#225f6b9e0337663e0d8e7cfd686fc2836ccace76"
|
||||
|
||||
Reference in New Issue
Block a user