mirror of
https://github.com/Fabio286/antares.git
synced 2025-02-13 02:00:36 +01:00
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);
|
||||
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 { valueToSqlString } from 'common/libs/sqlUtils';
|
||||
import * as mysql from 'mysql2/promise';
|
||||
|
||||
import { MySQLClient } from '../../clients/MySQLClient';
|
||||
import { SqlExporter } from './SqlExporter';
|
||||
@ -334,12 +333,10 @@ CREATE TABLE \`${view.Name}\`(
|
||||
}
|
||||
|
||||
async _queryStream (sql: string) {
|
||||
if (process.env.NODE_ENV === 'development') console.log('EXPORTER:', sql);
|
||||
const isPool = 'getConnection' in this._client._connection;
|
||||
const connection = isPool ? await (this._client._connection as mysql.Pool).getConnection() : this._client._connection;
|
||||
const connection = await this._client.getConnection();
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
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('error', dispose);
|
||||
|
@ -425,7 +425,6 @@ SET row_security = off;\n\n\n`;
|
||||
}
|
||||
|
||||
async _queryStream (sql: string) {
|
||||
if (process.env.NODE_ENV === 'development') console.log('EXPORTER:', sql);
|
||||
const connection = await this._client.getConnection();
|
||||
const query = new QueryStream(sql, null);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
|
@ -2,9 +2,18 @@ import * as Store from 'electron-store';
|
||||
import { defineStore } from 'pinia';
|
||||
const persistentStore = new Store({ name: 'notes' });
|
||||
|
||||
export interface ConnectionNote {
|
||||
uid: string;
|
||||
note: string;
|
||||
date: Date;
|
||||
}
|
||||
|
||||
export const useScratchpadStore = defineStore('scratchpad', {
|
||||
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: {
|
||||
changeNotes (notes: string) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user