What does HackerNews think of cornucopia?

Generate type-checked Rust from your PostgreSQL.

Language: Rust

#48 in Database
#30 in PostgreSQL
#50 in PostgreSQL
#113 in Rust
#44 in SQL
Some examples for anyone else reading:

Go: https://github.com/kyleconroy/sqlc

Rust: https://github.com/cornucopia-rs/cornucopia

This is my preferred method of interacting with databases now, if available.

Very flexible.

While we're on the subject of ORM's I really like the https://github.com/cornucopia-rs/cornucopia way of doing things.

Basically write SQL in a file and code generate a function that runs the SQL for you and puts it into a struct (this one is for rust)

I think there's a library to do the same thing with typescript.

For me, the best way to talk to the database is with SQL and I don't have to learn an ORMs way of doing it.

The best solution I've ever seen is this Rust library https://github.com/cornucopia-rs/cornucopia

You write plain SQL for you schema (just a schema.sql is enough) and plain SQL functions for your queries. Then it generates Rust types and Rust functions from from that. If you don't use Rust, maybe there's a library like that for your favorite language.

Optionally, pair it with https://github.com/bikeshedder/tusker or https://github.com/blainehansen/postgres_migrator (both are based off https://github.com/djrobstep/migra) to generate migrations by diffing your schema.sql files, and https://github.com/rust-db/refinery to perform those migrations.

Now, if you have simple crud needs, you should probably use https://postgrest.org/en/stable/ and not an ORM. There are packages like https://www.npmjs.com/package/@supabase/postgrest-js (for JS / typescript) and probably for other languages too.

If you insist on an ORM, the best of the bunch is prisma https://www.prisma.io/ - outside of the typescript/javascript ecosystem it has ports for some other languages (with varying degrees of completion), the one I know about is the Rust one https://prisma.brendonovich.dev/introduction