duality-labs / hapi-indexer

A Node.js based indexer for the Duality Cosmos chain
1 stars 0 forks source link

fix: easier nested SQL queries #44

Closed dib542 closed 10 months ago

dib542 commented 10 months ago

this PR switches out sql-template-strings for sql-template-tags to allow for easier SQL query nesting and reusing of abstracted sub-queries.

To use the ESM-only package sql-template-tags, the esbuild script needed to transpile the sql-template-tags package, here we transpile all packages except for sqlite3 which has some deep dependencies that aren't listed in its dependencies NPM packages. Thankfully the sqlite dependencies work with the transpiled app + other dependencies alright.

A shim function prepare was created to bridge the gap between the sql object format that db/sqlite3 expects and the sql format that sql-template-tags provides, which is a little different.