4 ms·
It's common to isolate all database calls to a specific part of the code. Usually each potential database operation has its own function, such as "update_user",
by Buttons840 3y ago
It's common to isolate all database calls to a specific part of the code. Usually each potential database operation has its own function, such as "update_user", or "get_spending_report", etc. This is good.
However, I think it's an anti-pattern to use both an ORM and still isolate your database code. It's like a double-abstraction where only one is needed. You have a write a bunch of CRUD functions and you have to use the ORM inside those functions. ORMs are complex, but they can be convenient to use, but if you're isolating all the database calls then the convenience of the ORM is wasted inside those half-baked CRUD functions. You end up getting the worst of both worlds.
So I say either (1) use raw SQL isolated inside CRUD functions, or (2) use an ORM and use the ORM abstraction freely throughout your code.
- deleted 3y ago[deleted]