Hacker News new | ask | show | jobs
by smallnamespace 1923 days ago
Any pitfalls that you encountered?

I'm trying to decide between this, or writing my own helpers around https://github.com/felixfbecker/node-sql-template-strings.

Also, have you found anything the solves typechecking of embedded expressions inside the SQL template?

For example, Webstorm will help you autocomplete your SQL, but you can still type:

   sql`SELECT * FROM foo WHERE barInt = ${bazStr}`

Would be nice to catch that with TypeScript magic rather than at runtime.
1 comments

slonik has no knowledge of the pg schema, so it cannot help with this.

You may want to look at something like https://github.com/adelsz/pgtyped. The downside is that dynamic queries are more challenging.

We have been looking at moving over to pgtyped, but it will be a hard transition because we do a fair amount of building up queries at runtime.