diff options
| author | James Barnett <noreply@jamesbarnett.xyz> | 2018-02-17 15:06:14 +0000 |
|---|---|---|
| committer | James Barnett <noreply@jamesbarnett.xyz> | 2018-02-17 15:06:14 +0000 |
| commit | b944a576f7cd0b6ea0edb0251f01a29ce4e0e86e (patch) | |
| tree | 36509d898e22892482e5ab1ed52d09fad0117e5d /query-executor.js | |
| parent | 9a730bfce2e0062f09201d0debe9b08a2ecb4d99 (diff) | |
| download | sql-plus-plus-b944a576f7cd0b6ea0edb0251f01a29ce4e0e86e.tar.xz sql-plus-plus-b944a576f7cd0b6ea0edb0251f01a29ce4e0e86e.zip | |
Add basic autocomplete for SQL keywords and tables
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 |