HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
pg-nano
pg-nano
TypeScript2024–2024
pg-nano / pg-nano

pg-nano

Postgres native driver for TypeScript: automatic type definitions for Postgres functions, instant schema updates, and Vite-inspired plugins

2Distinct people
8Mentions
0Explicit recommenders
108GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Postgres native driver for TypeScript: automatic type definitions for Postgres functions, instant schema updates, and Vite-inspired plugins

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

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

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 5:04:57 PM 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 week8 dated mentions

Observed mentions: 2024-09-06 16:23:03 UTC to 2024-12-15 19:11:11 UTC. Weeks start Monday, UTC.

01232024-09-02 00:00:00 UTC to 2024-09-09 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 commentsSep 22024-09-09 00:00:00 UTC to 2024-09-16 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-09-16 00:00:00 UTC to 2024-09-23 00:00:00 UTC (exclusive): 2 mentions; 1 submissions, 1 comments2024-09-23 00:00:00 UTC to 2024-09-30 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-09-30 00:00:00 UTC to 2024-10-07 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-10-07 00:00:00 UTC to 2024-10-14 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2024-10-14 00:00:00 UTC to 2024-10-21 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-10-21 00:00:00 UTC to 2024-10-28 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 commentsOct 212024-10-28 00:00:00 UTC to 2024-11-04 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-11-04 00:00:00 UTC to 2024-11-11 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-11-11 00:00:00 UTC to 2024-11-18 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-11-18 00:00:00 UTC to 2024-11-25 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-11-25 00:00:00 UTC to 2024-12-02 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-12-02 00:00:00 UTC to 2024-12-09 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments2024-12-09 00:00:00 UTC to 2024-12-16 00:00:00 UTC (exclusive): 1 mentions; 1 submissions, 0 commentsDec 9

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
Sep 22024-09-02 00:00:00 UTC2024-09-09 00:00:00 UTC101
Sep 92024-09-09 00:00:00 UTC2024-09-16 00:00:00 UTC000
Sep 162024-09-16 00:00:00 UTC2024-09-23 00:00:00 UTC211
Sep 232024-09-23 00:00:00 UTC2024-09-30 00:00:00 UTC000
Sep 302024-09-30 00:00:00 UTC2024-10-07 00:00:00 UTC000
Oct 72024-10-07 00:00:00 UTC2024-10-14 00:00:00 UTC101
Oct 142024-10-14 00:00:00 UTC2024-10-21 00:00:00 UTC000
Oct 212024-10-21 00:00:00 UTC2024-10-28 00:00:00 UTC000
Oct 282024-10-28 00:00:00 UTC2024-11-04 00:00:00 UTC000
Nov 42024-11-04 00:00:00 UTC2024-11-11 00:00:00 UTC000
Nov 112024-11-11 00:00:00 UTC2024-11-18 00:00:00 UTC000
Nov 182024-11-18 00:00:00 UTC2024-11-25 00:00:00 UTC000
Nov 252024-11-25 00:00:00 UTC2024-12-02 00:00:00 UTC000
Dec 22024-12-02 00:00:00 UTC2024-12-09 00:00:00 UTC303
Dec 92024-12-09 00:00:00 UTC2024-12-16 00:00:00 UTC110

What Hacker News says

8 sources

Ask HN: Seeking feedback on my Postgres TypeScript thing

Hey HN! I'm the creator of pg-nano. It's not an ORM, a query builder, or a basic query driver, but it's closest to the last one. The twist is, it's also a migration tool and a code generator. It's not production-ready yet (more on that below). The link: https://github.com/pg-nano/pg-nano/ It generates TypeScript bindings for your native Postgres routines (think `CREATE FUNCTION` or `CREATE PROCEDURE`, sorry for yelling). For views (e.g. CREATE VIEW), pg-nano can infer each column's “nullability” via static analysis. I plan to extend that inference to user-defined routines in the near future, but the generated types are already quite good. From your TypeScript application server, you call your Postgres routines with 100% type safety. The query driver uses libpq, the official C driver, under the hood. I've implemented a connection pool, aut
Read the rest
o-reconnect with exponential backoff, and query streaming on top of libpq. It scans a directory for `.sql` files and instantly updates your local database instance by diffing the current schema with the desired schema. It only drops data if absolutely necessary. Note that I haven't implemented production migrations yet, which will of course err on the safe side. I use a combination of static analysis (parsing your SQL) and introspection (querying Postgres system tables) at compile time to both generate the TypeScript bindings and the migration plan. The link again: https://github.com/pg-nano/pg-nano/ ~~~ I posted all this to get your feedback: - Could you see yourself using pg-nano? Why or why not? - Are there specific features you’d like to see, or concerns you have? I could really use some beta testers, but even your thoughts would help a great deal. ~~~ In order to get pg-nano production ready, I have a few things left to do. 1. Database seeding 2. Migrations in production 3. Transactions
4 points · Open discussion
You sound like someone who might be intrigued about what I'm building. Raw SQL (or PL/pgSQL which can be quite powerful) with generated, type-safe client "bindings" (TypeScript functions). It also includes "declarative SQL schema" (instantly update the schema of your dev DB on file save). Generated migrations and "seed scripts" are also on the roadmap. If any of that interests you, check it out (https://github.com/pg-nano/pg-nano). I would also love to discuss it with whoever's reading this on Discord (@aleclarson).
In Litdb – type safe SQL for JavaScript/TS
Hey, I'm developing a different approach that may appeal to a Kysely user such as yourself. I'd be glad to get your thoughts on it :) Raw SQL (or PL/pgSQL which can be quite powerful) with generated, type-safe client "bindings" (TypeScript functions). It also includes "declarative SQL schema" (instantly update the schema of your dev DB on file save). Generated migrations and "seed scripts" are also on the roadmap. If any of that interests you, check it out (https://github.com/pg-nano/pg-nano). I would also be happy to discuss it with you on Discord (@aleclarson).
In Litdb – type safe SQL for JavaScript/TS
Manual type declarations are error prone, tedious, and subject to drift. Meanwhile, query builders are clumsy and sometimes limiting or buggy, so I don't blame you for betting on raw SQL. I'm building a middle ground of sorts. Raw SQL (or PL/pgSQL which can be quite powerful) with generated, type-safe client "bindings" (TypeScript functions). It also includes "declarative SQL schema" (instantly update the schema of your dev DB on file save). Generated migrations and "seed scripts" are also on the roadmap. If any of that interests you, check it out (https://github.com/pg-nano/pg-nano). I would also love to discuss it with whoever's reading this on Discord (@aleclarson).
In Litdb – type safe SQL for JavaScript/TS
I'd love to get everyone's feedback on this library I made. I've found it helps a lot when writing a library that takes advantage of compile-time code generation. In the future, I think it could be cool to try and integrate jumpgen with bundlers, like Vite or Rollup, so your file generator can be used as a bundler plugin. Currently, jumpgen “generators” only have a programmatic API, but jumpgen will have a CLI as well, if you think that could be useful. Mostly though, jumpgen is intended as a “white label” library that is contained by your own CLI, if you have one. # Motivation Code generation can be useful for many tasks. I'm using code generation in my own libraries, pg-nano[1] and alien-rpc (in development). In pg-nano, I'm generating TypeScript functions that mirror Postgres functions (aka UDFs). In alien-rpc, I'm generating runtime m
Read the rest
etadata for RPC-style API routing. I could not find a library that simplifies the task of writing a code generator, so I made jumpgen. # What It Does It's designed to handle the burdens of implementing a “watch mode” for your generators. It also returns an event emitter, especially useful for logging. Your generator is free to work in relative paths, since jumpgen handles path resolution according to a user-provided root directory. It tracks which files your generator has read into memory and which directories your generator has listed. When those files/directories are changed or have files added/removed, your generator will rerun automatically (if watch mode is enabled). This even works with globs! I've also included a "dedent" helper function so you can indent any template literal without that excess indentation carrying over into the emitted files. # Feedback Wanted If this sounds interesting to you, I'd love to hear any comments or criticisms about the API, the readme, or whatever else. Thanks! [1]: https://github.com/pg-nano/pg-nano
In Jumpgen: A tiny framework for file generation in TypeScript
The main reason I didn't contribute my changes via PR is I wanted a package without "deparse" support, which adds considerably to the install size. I also didn't want pre-compiled binaries for every supported platform to be published to NPM, preferring a postinstall script that only downloads the necessary binary. I don't know how the walk function would be received by the original maintainers, as I didn't ask. > do you think it's possible to use your libraries to get the return type of an arbitrary postgres query, even if it's dynamic? Yes it is. I've solved that exact problem in pg-nano. I use the `describePrepared` feature of libpq: https://github.com/pg-nano/pg-nano/blob/4cca3dbe6be609c479e4...
In Show HN: Parse your Postgres queries into a fully-typed AST in TypeScript

Show HN: Parse your Postgres queries into a fully-typed AST in TypeScript

Hey all, I'm the creator of @pg-nano/pg-parser. I'm using it in pg-nano[1] to statically analyze Postgres schemas spread across multiple SQL files for a couple of reasons: 1. Each CREATE statement needs to be in topological order, so pg-nano's dev command can execute them without issue. 2. pg-nano has a plugin system like Vite that allows SQL generation based on the parsed schema. Probably to the surprise of no one, working with an untyped AST feels like you're back in the days of JavaScript, because well... you are. Most of you know by now just how great TypeScript and static types in general are, especially if you appreciate SQL. So why is this project worth sharing with you? Well, writing the AST type definitions by hand would have taken me way too much time. It would also be a bear to keep up-to-date as Postgres continues to evolve. T
Read the rest
o my surprise, I discovered that libpg_query, the C library used under-the-hood, includes JSON definitions in their /srcdata/ folder. I figured I could use them to generate the type definitions. Genius, right? Okay... maybe not genius, but still cool, I think. You see, those JSON definitions provided by libpg_query? They don't exactly contain the TypeScript definitions (was that obvious?). No, no. I had to translate them into TypeScript definitions. (I'm sure you could have done it, yes yes. But did you? No siree bob) It was pain-staking, but overall really not too hard. Time-consuming? Yes, but not as much as writing the type definitions by hand. So... was it worth it? Only time will tell. I hope you find it as useful as I do. And that's all I've got, so thanks for reading. P.S. The build for Windows is broken, so if anyone could lend a hand, you would be a true hero. [1]: https://github.com/pg-nano/pg-nano (not ready for production use)
116 points · Open discussion
This is one of 4 reasons why I'm building pg-nano [1] and honestly the main catalyst. The other 3 reasons are: I still want to call my Postgres functions from TypeScript in a safe manner; I want declarative schemas with generated migrations; and I want the ability to write compile-time plugins that can generate SQL or TypeScript through introspection. It's not released yet, but give it a look :) (v0.1 is almost done) [1]: https://github.com/pg-nano/pg-nano
In Show HN: Node.js ORM to query SQL database through an array-like API

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.