Why do I need to duplicate names in my schema?

For example:
name: text('name').notNull(),
name: text('name').notNull(),
Why do I need name twice? I can easily forget to update one or another creating a mess, like name: text('old_name') Any way to avoid it?
1 Reply
dj_klashndjksad
dj_klashndjksad10mo ago
You could have a separate naming conventions between your db layer and application layer (eg. camelCase for JS, snake_case for SQL). Drizzle lets you have full control over it. In other ORMs where it is done automatically by some magical naming strategies implementations, it could get really frustrating having to think every time, just to get the naming right. There can be many occasions when you want to do raw queries directly to your db. So to have the ability to know exactly what are the columns named in your db is just a big plus. You don't have to do any mental gymnastics around it. I remember it was really painfull to write raw queries to DB schemas build upon typeorm or prisma (didn't know about the mapping option back then), because the naming wasn't so straightforward. In my opinion, having the explicit control over your DB layer and APP layer naming is just something you could only benefit from in the long run.
Want results from more Discord servers?
Add your server