3 ms·
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
by rcme 3y ago
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
}
- w7 3y agoSome examples for anyone else reading: Go: https://github.com/kyleconroy/sqlc https://github.com/kyleconroy/sqlc Rust: https://github.com/cornucopia-rs/cornucopia https://github.com/cornucopia-rs/cornucopia This is my preferred method of interacting with databases now, if available. Very flexible.