• 0 Posts
  • 10 Comments
Joined 1 year ago
cake
Cake day: July 1st, 2023

help-circle
  • Yeah, that’s great, until you need to conditionally compose a query. Suddenly your pre baked queries are not enough. So you either:

    • create your own shitty ORM based on string concatenation
    • create your own shitty ORM
    • or use a well supported ORM, those almost always support query composition and native queries

    You write like it’s ORM vs native. ORMs let you write native queries and execute them while also doing all the tedious work for you such as:

    • mapping results to model objects
    • SQL injection safety
    • query composition
    • connection builders
    • transaction management

    So if you love native queries write native queries in an ORM which will do all the tedious shit for you.






  • I find that code written towards fulfilling some specific database design is usually a nightmare about 20minutes into the project. You end up with garbage semantics and interfaces because you’re building an entire app for the sake of storing stuff in a database. It’s an ass backwards approach to software development imo, software is about solving a human problem and data persistence is just one of the steps in the solution. Instead figure out what data your consumers need, then figure out what domain objects can be extracted from that, then plan how you will persist those domain objects. You’ll end up with less boilerplate, better naming of entities and services and you’ll also find that the words your team uses to talk to each other make sense to your business people not just your dba.


  • Microservices and document db’s go brrrrrrr. Data duplication is completely fine as long as there is only one source of truth that can be updated, all copies must be read only. Then the copies should either regularly poll the source or the source should publish update events that the copies can consume to stay in sync. It’s simple stuff but keeps your system way more available and fast than having multiple services talk to a shared db or worse, multiple services constantly fetching data through a proxy.