mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-27 19:36:00 +00:00
dbmodel tool initial import
This commit is contained in:
20
packages/dbmodel/lib/index.js
Normal file
20
packages/dbmodel/lib/index.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const load = require('./load');
|
||||
// const connect = require('./connect');
|
||||
// const dump = require('./dump');
|
||||
// const deploy = require('./deploy');
|
||||
// const build = require('./build');
|
||||
// const efmodel = require('./efmodel');
|
||||
|
||||
// const hooks = require('./hooks');
|
||||
const runAndExit = require('./runAndExit');
|
||||
|
||||
module.exports = {
|
||||
load,
|
||||
// connect,
|
||||
// dump,
|
||||
// deploy,
|
||||
// hooks,
|
||||
// build,
|
||||
// efmodel,
|
||||
runAndExit,
|
||||
};
|
||||
23
packages/dbmodel/lib/load.js
Normal file
23
packages/dbmodel/lib/load.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const _ = require('lodash');
|
||||
const dbgateApi = require('dbgate-api');
|
||||
|
||||
async function load({ connection, outputDir }) {
|
||||
await dbgateApi.loadDatabase(connection, outputDir);
|
||||
|
||||
// await connect(options);
|
||||
// const { client } = options;
|
||||
// const loadFunc = require(`./clients/${client}/load`);
|
||||
// options.databaseStructure = await loadFunc(options);
|
||||
// if (options.loadDataCondition) {
|
||||
// const { tables } = options.databaseStructure;
|
||||
// for (const tableName of _.keys(tables)) {
|
||||
// const table = tables[tableName];
|
||||
// if (!options.loadDataCondition(table)) continue;
|
||||
// const data = await query(options, `SELECT * FROM [${tableName}]`);
|
||||
// table.data = data;
|
||||
// }
|
||||
// }
|
||||
// return options;
|
||||
}
|
||||
|
||||
module.exports = load;
|
||||
16
packages/dbmodel/lib/runAndExit.js
Normal file
16
packages/dbmodel/lib/runAndExit.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const { createLogger } = require('pinomin');
|
||||
|
||||
const logger = createLogger('runAndExit');
|
||||
|
||||
async function runAndExit(promise) {
|
||||
try {
|
||||
await promise;
|
||||
logger.info('Success');
|
||||
process.exit();
|
||||
} catch (err) {
|
||||
logger.error({ err }, 'Processing failed');
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = runAndExit;
|
||||
Reference in New Issue
Block a user