HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
gajus
slonik
TypeScript2019–2026
gajus / slonik

slonik

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

24Distinct people
39Mentions
1Explicit recommenders
4.9KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

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

GitHub

Where it is used

No documented product use was verified in the last source check.

What people are saying

You're being downvoted, but I completely agree. If you are on Node and Postgres I highly recommend using slonik - it makes it easy to just write SQL but at the same time makes…

hn_throwaway_99 used a recommendation phrase. One indexed comment matches. This is a phrase match, not a verdict.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

Mentioned in the same Hacker News threads. That is not proof they are substitutes.

This week on Hacker News

Nov 9–Nov 16 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/16/2026, 7:27:27 AM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year39 dated mentions

Observed mentions: 2019-01-30 18:04:57 UTC to 2026-02-21 09:11:47 UTC.

0369122019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 3 mentions; 1 submissions, 2 comments20192020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 12 mentions; 1 submissions, 11 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments20222023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 11 mentions; 1 submissions, 10 comments2024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 4 mentions; 1 submissions, 3 comments2025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2026-01-01 00:00:00 UTC to 2027-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments. Incomplete calendar period.2026*

* An incomplete calendar period is marked with an outlined bar. Its count is not directly comparable with a full period.

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC312
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC303
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC12111
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC303
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC11110
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC413
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC202
2026 (partial)2026-01-01 00:00:00 UTC2027-01-01 00:00:00 UTC101

What Hacker News says

2 sources
There's two different approaches to solving sql composability issues: 1. Compiles-to-SQL domain specific languages. This category spans from ORM DSLs embedded in another programming language, like Ruby/Rail's ActiveRecord/AREL or Django's ORM; to stand-alone text-based languages like PRQL Pipelined Relational Query Language" (https://prql-lang.org) that a compiler program converts to SQL text or SQL files. The downside to the DSL option is that it requires practitioners be fluent in both the SQL query they want, and in the DLS language - to know how to obtain the SQL query in the DSL. 2. Query 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[] }` structure. The autho
Read the rest
r only needs to be fluent in SQL, and in the caller language, but do less to save you from the expressive limitations of SQL itself. I've found query fragment composition to be the sweet spot. Easy SQL queries remain trivial to express and understand, since it's Just SQL: sql`SELECT * FROM block WHERE id = ${args.id}` But you can DRY up repetition in the codebase through regular function calls. Abbreviated example from Notion's client code: function selectOfflinePageMetadata(args: { userId: string }) { return sql` SELECT offline_page.id, offline_page.space_id, offline_page.download_status, offline_page.last_downloaded_at, offline_page.last_downloaded_version, offline_page.last_downloaded_sync_cursor, offline_page.target_sync_cursor, CASE WHEN EXISTS ( SELECT 1 FROM offline_action WHERE offline_action.impacted_page_id = offline_page.id AND offline_action.origin_page_id = offline_page.id AND offline_action.autosync_type = 'not_autosynced' ) THEN 1 ELSE 0 END AS is_explicitly_offlined_origin, CASE WHEN EXISTS ( SELECT 1 FROM offline_action WHERE offline_action.impacted_page_id = offline_page.id AND offline_action.origin_page_id = offline_page.id AND offline_action.autosync_type = 'created_offline' ) THEN 1 ELSE 0 END AS is_offline_created_origin, CASE WHEN EXISTS ( SELECT 1 FROM offline_action WHERE offline_action.impacted_page_id = offline_page.id AND offline_action.origin_page_id = offline_page.id AND offline_action.autosync_type = 'frecent' ) THEN 1 ELSE 0 END AS is_autosynced_origin FROM offline_page WHERE offline_page.meta_user_id = ${args.userId} ` } function selectOfflinePageById(args: { userId: string pageId: string }) { const { userId, pageId, } = args return sql` SELECT * FROM (${selectOfflinePageMetadata({ userId })}) WHERE id = ${pageId} ` } function selectOfflineAutosyncedOrigins(args: { userId: string spaceId: string }) { const { userId, spaceId, } = args return sql` WITH offline_page_metadata AS ( ${selectOfflinePageMetadata({ userId })} ) SELECT offline_page_metadata.* FROM offline_page_metadata WHERE space_id = ${spaceId} AND is_autosynced_origin = 1 ORDER BY last_downloaded_at ASC ` } I'm not sure if it solves your "view problem", but it does a pretty good job for _my_ view problem.
In Parrot – type-safe SQL in Gleam, supports SQlite, PostgreSQL and MySQL

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.