mirror of https://github.com/Fabio286/antares.git
refactor: minor refactor
This commit is contained in:
parent
f13d4e6dce
commit
329246e2d8
|
@ -10,7 +10,7 @@ const queryLogger = ({ sql, cUid }: {sql: string; cUid: string}) => {
|
||||||
const mainWindow = require('electron').webContents.fromId(1);
|
const mainWindow = require('electron').webContents.fromId(1);
|
||||||
mainWindow.send('query-log', { cUid, sql: escapedSql, date: new Date() });
|
mainWindow.send('query-log', { cUid, sql: escapedSql, date: new Date() });
|
||||||
}
|
}
|
||||||
if (process.env.NODE_ENV === 'development') console.log(escapedSql);
|
if (process.env.NODE_ENV === 'development' && process.type === 'browser') console.log(escapedSql);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import * as exporter from 'common/interfaces/exporter';
|
import * as exporter from 'common/interfaces/exporter';
|
||||||
import { valueToSqlString } from 'common/libs/sqlUtils';
|
import { valueToSqlString } from 'common/libs/sqlUtils';
|
||||||
import * as mysql from 'mysql2/promise';
|
|
||||||
|
|
||||||
import { MySQLClient } from '../../clients/MySQLClient';
|
import { MySQLClient } from '../../clients/MySQLClient';
|
||||||
import { SqlExporter } from './SqlExporter';
|
import { SqlExporter } from './SqlExporter';
|
||||||
|
@ -334,12 +333,10 @@ CREATE TABLE \`${view.Name}\`(
|
||||||
}
|
}
|
||||||
|
|
||||||
async _queryStream (sql: string) {
|
async _queryStream (sql: string) {
|
||||||
if (process.env.NODE_ENV === 'development') console.log('EXPORTER:', sql);
|
const connection = await this._client.getConnection();
|
||||||
const isPool = 'getConnection' in this._client._connection;
|
|
||||||
const connection = isPool ? await (this._client._connection as mysql.Pool).getConnection() : this._client._connection;
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const stream = (connection as any).connection.query(sql).stream();
|
const stream = (connection as any).connection.query(sql).stream();
|
||||||
const dispose = () => (connection as mysql.PoolConnection).release();
|
const dispose = () => connection.end();
|
||||||
|
|
||||||
stream.on('end', dispose);
|
stream.on('end', dispose);
|
||||||
stream.on('error', dispose);
|
stream.on('error', dispose);
|
||||||
|
|
|
@ -425,7 +425,6 @@ SET row_security = off;\n\n\n`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async _queryStream (sql: string) {
|
async _queryStream (sql: string) {
|
||||||
if (process.env.NODE_ENV === 'development') console.log('EXPORTER:', sql);
|
|
||||||
const connection = await this._client.getConnection();
|
const connection = await this._client.getConnection();
|
||||||
const query = new QueryStream(sql, null);
|
const query = new QueryStream(sql, null);
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
|
|
@ -2,9 +2,18 @@ import * as Store from 'electron-store';
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
const persistentStore = new Store({ name: 'notes' });
|
const persistentStore = new Store({ name: 'notes' });
|
||||||
|
|
||||||
|
export interface ConnectionNote {
|
||||||
|
uid: string;
|
||||||
|
note: string;
|
||||||
|
date: Date;
|
||||||
|
}
|
||||||
|
|
||||||
export const useScratchpadStore = defineStore('scratchpad', {
|
export const useScratchpadStore = defineStore('scratchpad', {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
notes: persistentStore.get('notes', '# HOW TO SUPPORT ANTARES\n\n- [ ] Leave a star to Antares [GitHub repo](https://github.com/antares-sql/antares)\n- [ ] Send feedbacks and advices\n- [ ] Report for bugs\n- [ ] If you enjoy, share Antares with friends\n\n# ABOUT SCRATCHPAD\n\nThis is a scratchpad where you can save your **personal notes**. It supports `markdown` format, but you are free to use plain text.\nThis content is just a placeholder, feel free to clear it to make space for your notes.\n') as string
|
/** Global notes */
|
||||||
|
notes: persistentStore.get('notes', '# HOW TO SUPPORT ANTARES\n\n- [ ] Leave a star to Antares [GitHub repo](https://github.com/antares-sql/antares)\n- [ ] Send feedbacks and advices\n- [ ] Report for bugs\n- [ ] If you enjoy, share Antares with friends\n\n# ABOUT SCRATCHPAD\n\nThis is a scratchpad where you can save your **personal notes**. It supports `markdown` format, but you are free to use plain text.\nThis content is just a placeholder, feel free to clear it to make space for your notes.\n') as string,
|
||||||
|
/** Connection specific notes */
|
||||||
|
connectionNotes: persistentStore.get('connectionNotes', {}) as {[k: string]: ConnectionNote}
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
changeNotes (notes: string) {
|
changeNotes (notes: string) {
|
||||||
|
|
Loading…
Reference in New Issue