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
}
E.g. you could write a query like this:
And the library would generate a class like: