mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 00:36:01 +00:00
prettier
This commit is contained in:
@@ -11,7 +11,7 @@ module.exports = {
|
|||||||
requests: {},
|
requests: {},
|
||||||
|
|
||||||
handle_structure(conid, database, { structure }) {
|
handle_structure(conid, database, { structure }) {
|
||||||
const existing = this.opened.find((x) => x.conid == conid && x.database == database);
|
const existing = this.opened.find(x => x.conid == conid && x.database == database);
|
||||||
if (!existing) return;
|
if (!existing) return;
|
||||||
existing.structure = structure;
|
existing.structure = structure;
|
||||||
socket.emitChanged(`database-structure-changed-${conid}-${database}`);
|
socket.emitChanged(`database-structure-changed-${conid}-${database}`);
|
||||||
@@ -26,7 +26,7 @@ module.exports = {
|
|||||||
delete this.requests[msgid];
|
delete this.requests[msgid];
|
||||||
},
|
},
|
||||||
handle_status(conid, database, { status }) {
|
handle_status(conid, database, { status }) {
|
||||||
const existing = this.opened.find((x) => x.conid == conid && x.database == database);
|
const existing = this.opened.find(x => x.conid == conid && x.database == database);
|
||||||
if (!existing) return;
|
if (!existing) return;
|
||||||
if (existing.status == status) return;
|
if (existing.status == status) return;
|
||||||
existing.status = status;
|
existing.status = status;
|
||||||
@@ -36,7 +36,7 @@ module.exports = {
|
|||||||
handle_ping() {},
|
handle_ping() {},
|
||||||
|
|
||||||
async ensureOpened(conid, database) {
|
async ensureOpened(conid, database) {
|
||||||
const existing = this.opened.find((x) => x.conid == conid && x.database == database);
|
const existing = this.opened.find(x => x.conid == conid && x.database == database);
|
||||||
if (existing) return existing;
|
if (existing) return existing;
|
||||||
const connection = await connections.get({ conid });
|
const connection = await connections.get({ conid });
|
||||||
const subprocess = fork(process.argv[1], ['databaseConnectionProcess', ...process.argv.slice(3)]);
|
const subprocess = fork(process.argv[1], ['databaseConnectionProcess', ...process.argv.slice(3)]);
|
||||||
@@ -82,13 +82,16 @@ module.exports = {
|
|||||||
async queryData({ conid, database, sql }) {
|
async queryData({ conid, database, sql }) {
|
||||||
console.log(`Processing query, conid=${conid}, database=${database}, sql=${sql}`);
|
console.log(`Processing query, conid=${conid}, database=${database}, sql=${sql}`);
|
||||||
const opened = await this.ensureOpened(conid, database);
|
const opened = await this.ensureOpened(conid, database);
|
||||||
|
// if (opened && opened.status && opened.status.name == 'error') {
|
||||||
|
// return opened.status;
|
||||||
|
// }
|
||||||
const res = await this.sendRequest(opened, { msgtype: 'queryData', sql });
|
const res = await this.sendRequest(opened, { msgtype: 'queryData', sql });
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
|
|
||||||
status_meta: 'get',
|
status_meta: 'get',
|
||||||
async status({ conid, database }) {
|
async status({ conid, database }) {
|
||||||
const existing = this.opened.find((x) => x.conid == conid && x.database == database);
|
const existing = this.opened.find(x => x.conid == conid && x.database == database);
|
||||||
if (existing) return existing.status;
|
if (existing) return existing.status;
|
||||||
const lastClosed = this.closed[`${conid}/${database}`];
|
const lastClosed = this.closed[`${conid}/${database}`];
|
||||||
if (lastClosed) return lastClosed.status;
|
if (lastClosed) return lastClosed.status;
|
||||||
@@ -100,7 +103,7 @@ module.exports = {
|
|||||||
|
|
||||||
ping_meta: 'post',
|
ping_meta: 'post',
|
||||||
async ping({ conid, database }) {
|
async ping({ conid, database }) {
|
||||||
const existing = this.opened.find((x) => x.conid == conid && x.database == database);
|
const existing = this.opened.find(x => x.conid == conid && x.database == database);
|
||||||
if (existing) {
|
if (existing) {
|
||||||
existing.subprocess.send({ msgtype: 'ping' });
|
existing.subprocess.send({ msgtype: 'ping' });
|
||||||
}
|
}
|
||||||
@@ -116,11 +119,11 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
close(conid, database, kill = true) {
|
close(conid, database, kill = true) {
|
||||||
const existing = this.opened.find((x) => x.conid == conid && x.database == database);
|
const existing = this.opened.find(x => x.conid == conid && x.database == database);
|
||||||
if (existing) {
|
if (existing) {
|
||||||
existing.disconnected = true;
|
existing.disconnected = true;
|
||||||
if (kill) existing.subprocess.kill();
|
if (kill) existing.subprocess.kill();
|
||||||
this.opened = this.opened.filter((x) => x.conid != conid || x.database != database);
|
this.opened = this.opened.filter(x => x.conid != conid || x.database != database);
|
||||||
this.closed[`${conid}/${database}`] = {
|
this.closed[`${conid}/${database}`] = {
|
||||||
status: {
|
status: {
|
||||||
...existing.status,
|
...existing.status,
|
||||||
|
|||||||
Reference in New Issue
Block a user