diff options
| author | James Barnett <noreply@jamesbarnett.xyz> | 2018-02-20 21:44:28 +0000 |
|---|---|---|
| committer | James Barnett <noreply@jamesbarnett.xyz> | 2018-02-20 21:44:28 +0000 |
| commit | b81c0f834f7f2285c40cfd57eb2943140025edad (patch) | |
| tree | 2c45b5d844e2a8413f3189090e5f6373226f4fca /query-executor.js | |
| parent | 52f6783f63d2e2f52e06d14a97b5e00eab8ac1c0 (diff) | |
| download | sql-plus-plus-b81c0f834f7f2285c40cfd57eb2943140025edad.tar.xz sql-plus-plus-b81c0f834f7f2285c40cfd57eb2943140025edad.zip | |
Dynamically create query executors - WIP
Diffstat (limited to 'query-executor.js')
| -rw-r--r-- | query-executor.js | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/query-executor.js b/query-executor.js index 871da9e..0c5b440 100644 --- a/query-executor.js +++ b/query-executor.js @@ -1,30 +1,39 @@ "use strict"; -const { ipcRenderer } = require("electron"); +const { remote, ipcRenderer } = require("electron"); const { Pool } = require("pg"); +const executorId = require("uuid/v1")(); + +const connectionConfig = remote.getCurrentWindow().connectionConfig; + const connectionPool = new Pool({ - user: "postgres", - host: "localhost", + user: connectionConfig.username, + host: connectionConfig.host, database: "postgres", - password: "", - port: 5432 + password: connectionConfig.password, + port: connectionConfig.port }); -ipcRenderer.on("queryExecutor.runQuery", (event, payload) => { - - connectionPool.query(payload.query, (err, res) => { +// Initialisation completed +ipcRenderer.send("queryExecutor.initialiseConnectionCallback", executorId); - console.log(err, res) +ipcRenderer.on("queryExecutor.runQuery", (event, payload) => { - ipcRenderer.send("queryExecutor.runQueryComplete", { - "error": err, - "result": res, - "editorInstanceId": payload.editorInstanceId + if(payload.queryExecutorId === executorId) { + connectionPool.query(payload.query, (err, res) => { + + console.log(err, res) + + ipcRenderer.send("queryExecutor.runQueryComplete", { + "error": err, + "result": res, + "editorInstanceId": payload.editorInstanceId + }); + }); - - }); - + } + }); ipcRenderer.on("queryExecutor.queryTableMetadata", (event, payload) => { |