How to get good at Drizzle?
Hello I am currently having a huge problem with Drizzle, and relational databases in general.
I start writing my schema, but after finishing a few tables (5-10) I get overwhelmed by the amount of objects and relations happening between them and don't know what to do, and how to properly connect them together.
At this point I just delete my entire schema and start writing it from scratch, in hopes of implementing it correctly this time. This process repeats a few times and I never actually finish the database.
I am also very confused when thinking about the later part of the application, where I would have to insert the data, as nested objects would have to be inserted in multiple layers which sounds so complicated at scale.
Example having a
product
with variants
of that product which have prices
. I would have to create a price, then assign the price_id to a variant, then do the same for a product. The logic seems backwards, so instead of thinking about inserting a product I first have to insert a price then variant then product. And all that at just 3 levels of nesting.
The example above would be even messier in code, while I am thinking of inserting something more elegant like this:
Do you have any tips on staying organised and not getting overwhelmed when writing Drizzle schemas?5 Replies
It will come with experience, at first many people get overwhelmed, usually when they learn too much stuff at once. Start small and improve your skills and it will be your second nature. Alternative is to use some 1st class ORM like mikro-orm, it has Unit Of Work pattern built in that simplifies business logic a loooot (simillar to ef core from c#). If your app is mainly CRUD I highly suggest give it a try or simmilar orm like TypeOrm etc. Drizzle is good, but it is not my go-to technology for all projects (specially when I know I will be making a lot of business logic; mapping is so time consuming). My tip is to make pseudo code with logic you would need to implement some feature without actually coding, I mean some transactional script with commands like: do this, then do this, take that and if this is something do this, then make something etc.
I really want to learn Drizzle but I might as well try some of the other ORMs a try if that will help me get comfortable with SQL. I really need the experience, since I've just started working with this database stuff like a month ago. I've never been so confused with any technology or algorithm before as much as SQL and that's what is bothering me the most.
Thank you for the advice, I will work hard and maybe create few less complex projects before starting something a little larger.
Hey đź‘‹ you can quickly try and learn with https://drizzle.run and following some examples from https://orm.drizzle.team/learn/guides
Drizzle Run
Drizzle Run
Drizzle ORM - Guides
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
(Some guides are too specific and will not work in Drizzle Run like vectors).
I was thinking about some “super starter examples” like a demo of a chat modeling, blog with comments etc. Is it something that could help new comers?
Thank you, these sound good, I will try to recreate them.