From b944a576f7cd0b6ea0edb0251f01a29ce4e0e86e Mon Sep 17 00:00:00 2001 From: James Barnett Date: Sat, 17 Feb 2018 15:06:14 +0000 Subject: Add basic autocomplete for SQL keywords and tables --- query-executor.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'query-executor.js') 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 -- cgit v1.2.3