Slonik: A PostgreSQL client with strict types, detailed logging, and assertions
1–10 of 19 posts
Re: Slonik: A PostgreSQL client with strict types, detailed logging, and assertions
#2Another nice thing about slonik is that it is built on top of https://github.com/brianc/node-postgres. One gets all the benefit of node-pg with the nicer dev experience of slonik.
Re: Slonik: A PostgreSQL client with strict types, detailed logging, and assertions
#3Re: Slonik: A PostgreSQL client with strict types, detailed logging, and assertions
#4Last few years I've been using a similar workflow with something like https://www.npmjs.com/package/pg-template-tag in combination with `pg`. I'm never going back to ORMs and query builders.
Ideally the system would require you to use the tag and prohibit a plain ol string.
Re: Slonik: A PostgreSQL client with strict types, detailed logging, and assertions
#5Re: Slonik: A PostgreSQL client with strict types, detailed logging, and assertions
#6Last few years I've been using a similar workflow with something like https://www.npmjs.com/package/pg-template-tag in combination with `pg`. I'm never going back to ORMs and query builders.
The template tag solution is cute but dangerous if you can accidentally leave off the `SQL` tag and the query still works. Ideally the system would require you to use the tag and prohibit a plain ol string.
Re: Slonik: A PostgreSQL client with strict types, detailed logging, and assertions
#7Last few years I've been using a similar workflow with something like https://www.npmjs.com/package/pg-template-tag in combination with `pg`. I'm never going back to ORMs and query builders.
The template tag solution is cute but dangerous if you can accidentally leave off the `SQL` tag and the query still works. Ideally the system would require you to use the tag and prohibit a plain ol string.
Re: Slonik: A PostgreSQL client with strict types, detailed logging, and assertions
#8Great to see this package here. We have been using slonik for over a year now with few regrets. I am not a fan of query builders. Query builders work for simple inserts or updates. For really complex queries, nothing beats writing SQL inside of the sql template tag. Another nice thing about slonik is that it is built on top of https://github.com/brianc/node-postgres . One gets all the benefit of node-pg with the nice…
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.Re: Slonik: A PostgreSQL client with strict types, detailed logging, and assertions
#9Last few years I've been using a similar workflow with something like https://www.npmjs.com/package/pg-template-tag in combination with `pg`. I'm never going back to ORMs and query builders.
[1] https://github.com/felixfbecker/node-sql-template-strings