Live data from Hacker News

Show HN: Bun-sqlgen – Type-safe raw SQL for Bun, no ORM

github.com

21–30 of 44 posts

Re: Show HN: Bun-sqlgen – Type-safe raw SQL for Bun, no ORM

#21

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/

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

Re: Show HN: Bun-sqlgen – Type-safe raw SQL for Bun, no ORM

#22
post #12

Earlier quoted context omitted.

Can you describe how it's the same and how it's different than SQLx (a Rust thing)?

I actually took a lot of inspiration from sqlx, which is really nice. The main differences are: - in JS/TS you don't have compile-time scripts that you can run like with Rust's macros, so you need to run a codegen command before running the type checks (disadvantage) - I had to create a TS parser that goes and finds the tagged template functions with the sql statements, while sqlx has them "for free" because sql stat…

Very interesting! I spent a long session in a harness the other day getting pglite to the point it would work reliably in a browser for a specific use case I had. The key was NOT using that environment to run the SQLx validation, but just having a real long running Postgres for local builds + CI, and simply creating and dropping a database for that run.

Used pglite-oxide for the Electron build and then we went off into the weeds and ported pglite so it could run in iOS for iOS apps. The easiest way to do this is to just do it as a plain old Mac app first and get it working there first.

I’ll open source this if I figure out if we can maintain it and document it.

Re: Show HN: Bun-sqlgen – Type-safe raw SQL for Bun, no ORM

#24

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/

And sqlx on the Rust side just for completeness

Re: Show HN: Bun-sqlgen – Type-safe raw SQL for Bun, no ORM

#27

I don’t understand why no one is making SQL a first class citizen in a language, there are tons of languages out there that are extendable, how hard can it be, enough of DSL and generated type-safe application code which is a DSL in reverse order.

Microsoft has been doing this for a long time: https://learn.microsoft.com/en-us/dotnet/csharp/linq/

Re: Show HN: Bun-sqlgen – Type-safe raw SQL for Bun, no ORM

#28
post #13
post #6

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?

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.

bun truly made itself unappealing when it did the vibe coded port to rust

Re: Show HN: Bun-sqlgen – Type-safe raw SQL for Bun, no ORM

#30
post #21

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/

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

Kysely is best choice for TS imo.
Post reply on HN