Top
Best
New

Posted by ilbert 4 hours ago

Show HN: Bun-sqlgen – Type-safe raw SQL for Bun, no ORM(github.com)
43 points | 21 comments
giovannibonetti 1 hour ago|
Those looking for a more mature solution in this space will probably enjoy SQLc [1]. It was initially developed for Go applications, but over the years it got pluggins for many other languages, including JavaScript/Typescript.

[1] https://sqlc.dev/

zareith 33 minutes ago|
It may be a good choice for golang, but support for other languages is not as great.

I remember creating a PR [1] for some very obvious issues with Typescript generator for better-sqlite3 some two years ago which never received any attention from maintainers. There are bunch of such PRs languishing in obscurity in their repos.

[1] https://github.com/sqlc-dev/sqlc-gen-typescript/pull/45

genshii 1 hour ago||
This is cool, but when the very first paragraph of the readme is clearly LLM generated, it makes me doubt the quality of the project.
lacy_tinpot 1 hour ago||
LLM generated docs/readmes are at this point old news.
ilbert 1 hour ago||
Yeah, I'm still iterating on the docs
zareith 27 minutes ago||
This looks great. I love using pgtyped, but have missed a solution that works well for sqlite.
rankdiff 2 hours ago||
sqlc is worth a mention.

https://sqlc.dev

psc007 3 hours ago||
Can you make it work/ does it work with Porsager-Postgres in modnes which buns Postgres client is «based on»?
ilbert 3 hours ago|
I think with some tweaks to the TS parser that goes and looks for the sql statements it's doable. How are you solving the problem right now?
allthetime 1 hour ago||
Kysely rules
sHooKDT 3 hours ago||
Nice project, thanks! I was looking for something like that for quite a while.

Any chance to get it to work with Node?

Unfortunately in my opinion and experience Bun is not really suitable for production. Does it have anything special which makes this possible?

ilbert 3 hours ago||
I was targeting Bun because I really like its built-in SQL module. I can tweak the TS parser to look for e.g. postgres.js tagged template functions and make it work for that as well. I don't really see any blockers
tomComb 2 hours ago||
Yes, bun is good locally, but need node support for deployment. So while the bun specific stuff sounds great I feel I need to avoid it.
psc007 3 hours ago||
Support for postgis?
ilbert 3 hours ago|
The cli config supports specifying the PGLite extensions (the codegen uses PGLite as an in-memory light postgres), see this example: https://github.com/ilbertt/bun-sqlgen/tree/main/examples/wit....

You'll still probably have to manually override some column types using PG comments like: https://github.com/ilbertt/bun-sqlgen/blob/dee757ebc9c38aec7...

PGLite extensions: https://pglite.dev/extensions/#postgis

danr4 3 hours ago|
pretty cool