I stopped working with ORMs years ago, replaced with a type-safe query builder (types being generated from the database schema)
Specifically using @jooq.org in Java/Kotlin land, though SQLDelight looks good too for simpler usecases.
Still haven't tried JS/TS ones (Drizzle, Knex, Kysely, Zapatos)
I honestly think the best design is to abstract away the SQL from the business logic… by hand. Just write some functions that interact with the database.
IMO, As long as the db query isn’t mixed in the business logic, you’re doing great. ORMs are super overkill and often just limit what you can do
Yes. SQL is already an abstraction layer. Adding another abstraction, which is bound to be incomplete and leaky,* just makes people learn *two* abstraction layers.
Comments
Specifically using @jooq.org in Java/Kotlin land, though SQLDelight looks good too for simpler usecases.
Still haven't tried JS/TS ones (Drizzle, Knex, Kysely, Zapatos)
IMO, As long as the db query isn’t mixed in the business logic, you’re doing great. ORMs are super overkill and often just limit what you can do
(data access layer .. also the Indian dish)
In fact, ive grown to like a nosql approach with TS for types to govern it instead. More messy underwater but so much easier to manage.
you're doing something right 😄
* Law of Leaky Abstractions: https://www.joelonsoftware.com/2002/11/11/the-law-of-leaky-abstractions/