mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-24 01:25:59 +00:00
export model WIP
This commit is contained in:
@@ -95,4 +95,13 @@ module.exports = {
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
async getNewArchiveFolder({ database }) {
|
||||
if (!(await fs.exists(path.join(archivedir(), database)))) return database;
|
||||
let index = 2;
|
||||
while (await fs.exists(path.join(archivedir(), `${database}${index}`))) {
|
||||
index += 1;
|
||||
}
|
||||
return `${database}${index}`;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const uuidv1 = require('uuid/v1');
|
||||
const connections = require('./connections');
|
||||
const archive = require('./archive');
|
||||
const socket = require('../utility/socket');
|
||||
const { fork } = require('child_process');
|
||||
const { DatabaseAnalyser } = require('dbgate-tools');
|
||||
@@ -238,6 +239,12 @@ module.exports = {
|
||||
return res;
|
||||
},
|
||||
|
||||
exportModel_meta: 'post',
|
||||
async exportModel({ conid, database }) {
|
||||
const archiveFolder = await archive.getNewArchiveFolder({ database });
|
||||
return { archiveFolder };
|
||||
},
|
||||
|
||||
// runCommand_meta: 'post',
|
||||
// async runCommand({ conid, database, sql }) {
|
||||
// console.log(`Running SQL command , conid=${conid}, database=${database}, sql=${sql}`);
|
||||
|
||||
@@ -53,11 +53,20 @@
|
||||
currentDatabase.set(null);
|
||||
};
|
||||
|
||||
const handleExportModel = async () => {
|
||||
const resp = await axiosInstance.post('database-connections/export-model', {
|
||||
conid: connection._id,
|
||||
database: name,
|
||||
});
|
||||
showSnackbarSuccess(`Saved to archive ${resp.data.archiveFolder}`);
|
||||
};
|
||||
|
||||
return [
|
||||
{ onClick: handleNewQuery, text: 'New query', isNewQuery: true },
|
||||
{ onClick: handleImport, text: 'Import' },
|
||||
{ onClick: handleExport, text: 'Export' },
|
||||
{ onClick: handleSqlGenerator, text: 'SQL Generator' },
|
||||
{ onClick: handleExportModel, text: 'Export DB model' },
|
||||
|
||||
_.get($currentDatabase, 'connection._id') == _.get(connection, '_id') &&
|
||||
_.get($currentDatabase, 'name') == name && { onClick: handleDisconnect, text: 'Disconnect' },
|
||||
@@ -78,6 +87,7 @@
|
||||
import getElectron from '../utility/getElectron';
|
||||
import openNewTab from '../utility/openNewTab';
|
||||
import AppObjectCore from './AppObjectCore.svelte';
|
||||
import { showSnackbarSuccess } from '../utility/snackbar';
|
||||
export let data;
|
||||
|
||||
function createMenu() {
|
||||
|
||||
Reference in New Issue
Block a user