diff options
Diffstat (limited to 'query-executor.js')
| -rw-r--r-- | query-executor.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/query-executor.js b/query-executor.js index 58189b5..7bd836d 100644 --- a/query-executor.js +++ b/query-executor.js @@ -25,3 +25,34 @@ ipcRenderer.on("queryExecutor.runQuery", (event, payload) => { }); }); + +ipcRenderer.on("queryExecutor.queryTableMetadata", (event, payload) => { + + let tableMetadata = {}; + + let tableDataQuery = + "SELECT c.table_schema || '.' || c.table_name identifier, c.column_name " + + "FROM information_schema.columns c " + + "WHERE c.table_schema != 'pg_catalog'"; + + connectionPool.query(tableDataQuery, (err, res) => { + + console.log(err, res) + + res.rows.forEach((row) => { + if(tableMetadata.hasOwnProperty(row.identifier)) { + tableMetadata[row.identifier].push(row.column_name); + } + else { + tableMetadata[row.identifier] = [row.column_name]; + } + }) + + ipcRenderer.send("queryExecutor.queryTableMetadataComplete", { + "error": err, + "result": tableMetadata + }); + + }); + +});
\ No newline at end of file |