Hacker GitHub

← All repos

gajus/slonik

View on GitHub ↗ ★ 4,937 TypeScript

A Node.js PostgreSQL client with runtime and build time type safety, and composable SQL.

39 mentions on Hacker News by 24 people: 4 stories, 35 comments · first 2019-01-30 · latest 2026-02-21

Mentions per year 39 mentions · busiest year 2021 (12)
20082026
  1. Slonik uses template strings to do this inline, safely. https://github.com/gajus/slonik
  2. …fragment literals in the caller programming language, like sql`name = ${name}` in TypeScript (eg https://github.com/gajus/slonik ). These are usually thin abstraction over concatenating a `{ queryText: string[], queryArgs: T[] }`…
  3. Zod is the default validator for https://github.com/gajus/slonik . Zod alone accounts for a significant portion of the CPU time.
  4. There is Slonik [1] for instance. [1] https://github.com/gajus/slonik
  5. Didn’t use myself, but AFAIK slonik library is doing what you’ve described: https://github.com/gajus/slonik
    comment by user432678 · 2024-09-10 · in Sqlc: Compile SQL to type-safe code
  6. ▲ 1
    Show HN: TypeScript SQL Query API Engine for Postgres
    story by ardsh · 2024-09-06 · 1 comment
  7. …so that you can't accidentally pass in a normal string-interpolated string. Examples: - slonik: https://github.com/gajus/slonik?tab=readme-ov-file#protectin... - postgres.js: https://github.com/porsager/postgres?tab=readme-ov-file#quer...
  8. You can already use postgres with Slonik. https://github.com/gajus/slonik#user-content-slonik-how-are-... It is not going to be the default because it is way slower. https://github.com/gajus/slonik/actions/runs/6616647651 Test…
  9. ▲ 1
    Slonik: PostgreSQL client for Node.js with runtime validation
    story by gajus · 2023-10-15 · 0 comments
  10. Also see: https://github.com/gajus/slonik
  11. …* FROM foo WHERE bar = \{inputParam}") which is exactly what many NodeJS libraries due, e.g. Slonik https://github.com/gajus/slonik , like sql`SELECT * FROM foo WHERE bar = ${inputParam}`;
    comment by hn_throwaway_99 · 2023-09-25 · in JEP Draft: String Templates (Final)
  12. …it's necessary to use Zod/runtime validation everywhere, but it's a nice tool to have on hand. [1] https://github.com/gajus/slonik
  13. …and accidentally one can make an SQL injection with these: https://github.com/porsager/postgres https://github.com/gajus/slonik
    comment by ttfkam · 2023-06-29 · in Is ORM still an anti-pattern?
  14. Have you tried Slonik ( https://github.com/gajus/slonik )? It won't generate types from queries automatically, but it encourages writing SQL vs. a query builder and allows type annotations of queries with Zod. Query results are validated…
    comment by mavbo · 2023-05-12 · in The Epic Stack
  15. Definitely a lot of misconceptions around how this would work. Just check out something like slonik, https://github.com/gajus/slonik , which is an excellent implementation. The example you gave actually isn't valid, because what you're…
  16. …Template strings in TypeScript allow you to safely write SQL directly, still with type checking: https://github.com/gajus/slonik#readme
    comment by hn_throwaway_99 · 2023-01-25 · in Kysely: TypeScript SQL Query Builder
  17. …cool project but I do think query builders ARE generally an anti-pattern. I'm a huge fan of slonik, https://github.com/gajus/slonik#readme , which uses template strings for SQL and has recently come a long way with its strong typing…
    comment by hn_throwaway_99 · 2023-01-25 · in Kysely: TypeScript SQL Query Builder
  18. Slonik comes pretty close https://github.com/gajus/slonik . It does not inspect your DB schema, but has worked very well in our SQL-heavy architecture.
    comment by cheeseface · 2023-01-24 · in Kysely: TypeScript SQL Query Builder
  19. …use cases for runtime validation, namely when dealing with external inputs/databases, e.g. https://github.com/gajus/slonik#user-content-runtime-validat... Flow had [flow-runtime]( https://github.com/gajus/flow-runtime ), which was nice.…
  20. …want is something like slonik which is more focused on querying than relational mapping. [0]: https://github.com/gajus/slonik
    comment by hardwaresofton · 2022-09-29 · in Flyweight: An ORM for SQLite
  21. …develop Zapatos, but Slonik and pg-typed are probably better known. https://jawj.github.io/zapatos/ https://github.com/gajus/slonik https://pgtyped.vercel.app/
  22. I've been a huge fan of Slonik, https://github.com/gajus/slonik , which makes it easy and safe to write direct SQL queries. The author of Slonik had a good article about the downsides of query builders, previously discussed on HN, that I…
    comment by hn_throwaway_99 · 2021-11-26 · in Our journey in dropping the ORM in Go
  23. …, but a few years after I wrote that (and mostly didn't use it) I found https://github.com/gajus/slonik which was very similar and much more fleshed-out; I rolled _some_ of its concepts and patterns into sql-athame.
  24. In this space but a little lighter: https://github.com/gajus/slonik
  25. …of your DB. Some contributors have commented they are working on something similar for Slonik, https://github.com/gajus/slonik/pull/267#issuecomment-840559...
    comment by hn_throwaway_99 · 2021-06-18 · in DenoDB
  26. …are littered with knex.raw statements. This was discussed at length in this slonik issue, https://github.com/gajus/slonik/issues/42 , with some recommendations for migrations functionality.
    comment by hn_throwaway_99 · 2021-06-18 · in DenoDB
  27. Give slonik a try. It's a very nice step up from raw drivers https://github.com/gajus/slonik
    comment by indeyets · 2021-06-18 · in DenoDB
  28. …have mistakes like SQL injections: https://gajus.medium.com/stop-using-knex-js-and-earn-30-bf41... https://github.com/gajus/slonik
    comment by hn_throwaway_99 · 2021-06-18 · in DenoDB
  29. https://github.com/gajus/slonik
    comment by domlebo70 · 2021-04-21 · in Prisma – ORM for Node.js and TypeScript
  30. …topic for a different discussion. We have a set of DAO components that access the DB using Slonik, https://github.com/gajus/slonik (overview explaining the rationale for this library is at https://medium.com/@gajus/bf410349856c ). Our app…
    comment by hn_throwaway_99 · 2021-04-20 · in Node.js 16 Available Now
  31. I like the idea and project goals. There are however gems like this in the source: https://github.com/gajus/slonik/blob/master/src/routines/exe... You can spend an hour trying to reason about the control flow of that triple try/catch…
  32. ▲ 60
    Slonik: A PostgreSQL client with strict types, detailed logging, and assertions
    story by sarahdellysse · 2021-03-10 · 18 comments
  33. On a related note, I've become a gigantic fan of Slonik, https://github.com/gajus/slonik , which simultaneously (a) makes it extremely difficult to expose SQL injection attacks while (b) still letting you write SQL in a very "natural" way…
  34. Specifically in Node.js, https://github.com/gajus/slonik has drastically improved the experience of writing and composing SQL queries. I am the author of Slonik.
  35. How is it different from Slonik? https://github.com/gajus/slonik
  36. …Another one in a similar vein with strict typing and really nice SQL interpolation for Postgres: https://github.com/gajus/slonik
  37. …Froala - https://www.froala.com/wysiwyg-editor SequelizeJS - https://sequelize.org/master/ Slonik - https://github.com/gajus/slonik WS - https://github.com/websockets/ws Socket.io - https://socket.io/
    comment by truth_seeker · 2019-09-10 · in Running GitHub on Rails 6.0
  38. …check out `slonik` [0]. It doesn't support migrations, but there are other tools for that [1]. [0] https://github.com/gajus/slonik [1] https://github.com/mmkal/slonik-tools
    comment by lhnz · 2019-09-10 · in Running GitHub on Rails 6.0
  39. ▲ 2
    Show HN: Slonik/PostgreSQL client with strict types, logging and assertions
    story by boshomi · 2019-01-30 · 0 comments