Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There are libraries that flip the concept of an ORM on its head. Instead of a library that allows lazy query composition, you write your queries and the library generates the code for that query at compile time. It’s a much better model in my opinion.

E.g. you could write a query like this:

    getUser:
    SELECT * FROM users WHERE id = ?
And the library would generate a class like:

    class GetUserQuery {
        static getUser(id: String): GetUserQueryResult
    }



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.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: