DT
Drizzle Teamitsyoboieltr

eslint-plugin-drizzle add "db" as default

Is there a reason why it is automatically applied for every delete function? I think most users would use "db" const anyway. If you decide not to make "db" default, can we somehow override this for all rules? it sounds very cumbersome to specify this for every rule (imagine if even more get added in the future)
I
itsyoboieltr165d ago
cc: @Angelelz
A
Angelelz165d ago
We shipped it with not default and were hoping to get some feedback. But there is an option drizzleObjectName where you can define it
I
itsyoboieltr165d ago
My feedback is that I added it into my app, and it immediately broke my api routes that are named "delete", which should be pretty common in CRUD apps but this needs to be declared for every rule separately, right?
A
Angelelz165d ago
TBH I think most people will only need it in the delete I'm also not sure if using db as default might have unintended consecuences, when users don't notice that, use the plugin trusting it will yell at them on delete, and then finding out that it didn't work becuase their db object is named database
I
itsyoboieltr165d ago
the current default also seems to have unintended consequences unfortunately
A
Angelelz165d ago
That's the kind of stuff we were afraid of when we publish. I think it's better to have a false positive and an false negative That's my opinion but the feedback is welcome
I
itsyoboieltr165d ago
I wish you could check somehow if the .delete method is called somehow on a drizzle db object or something similar, instead of manually specifying the variable name
A
Angelelz165d ago
I looked into that, I'm not sure yet if it's possible. If it is, it will involve including an additional parser and complications during testing. I looked into other plugins and I couldn't find one that have a similar approach in the assertion
I
itsyoboieltr165d ago
I think the biggest problem with the lint plugin is that your project is destined to break just by adding it. The only way to not have your app break, is by configuring the "drizzleObjectName" variable. But it is not plug-n-play without it. Normally, lint plugins work without any specific configuration. and let's not even talk about changing the variable in the code, but forgetting about changing it in the eslintrc 😄 it is rare, but could also happen but overall, great initiative!
A
Angelelz165d ago
Yep I get what you're saying. This is the first version though 👍
I
itsyoboieltr165d ago
looking forward to how it plays out in the future then 😄
A
Angelelz165d ago
I'd suggest you use the beta version we just published this morning right now it has a false negative if you use the drizzleObjectName like db, but it's a nested object like this.data.db.delete(...)
I
itsyoboieltr165d ago
thanks!
AS
Andrii Sherman165d ago
@itsyoboieltr, thanks for your feedback! We will improve ESLint to make it work as you mentioned and check the exact drizzle type. Still, I'm not sure how to make it work properly. Personally, I also needed this check on a project I'm working on, and releasing it in this state was a good solution for now. Yes, you need to specify a name for each rule, but we have only 2 of them. Before adding any new ones with the same problem, we will try to improve it. For now, I see the current setup as a good combination of the needed helper and time to develop it. Also, if you have any expertise on how to check a specific type in TS AST, I would love to get any hints on how to do it
A
Angelelz165d ago
@Andrew Sherman Are you using it in the drizzle studio codebase? 😅
AS
Andrii Sherman165d ago
no 😅
A
Angelelz165d ago
You should, don't delete our precious data!
I
itsyoboieltr165d ago
the current solution, is just putting it as part of the template I am developing, so everytime I start a new project, the rules are already there https://github.com/itsyoboieltr/dbest-stack/blob/b44dbad9595cc2aeff27f807f441497eb78a3302/package.json#L70C2-L70C2
GitHub
dbest-stack/package.json at b44dbad9595cc2aeff27f807f441497eb78a330...
Contribute to itsyoboieltr/dbest-stack development by creating an account on GitHub.
A
Angelelz165d ago
Good stuff!
Want results from more Discord servers?
Add your server
More Posts
Does Promise.all work correct in transactions?As I just found out, pg only works with one query (or more if there is more than one connection), soFindFirst Config Optional `with`Hi, I am trying to do something like an optional findFirst config here. i am expecting the resultTypSupabase primary key typeWhen I run `introspect`, the primary key of my tables look something like this: ```id: bigint("id", Supabase/postgres get query is stuck on prod appHi, I'm coming across an issue with my discord bot, I currently have a query that checks if an usercreate exportable types for frontend servicesI feel like I'm missing something fundamental. I can create my Drizzle schema `user = mysqlTable('uno migrations for pgenums in drizzle-kitnot able to see migrations generated for pgenums in drizzle kit, is this not implemented yet or maybProperty '[IsDrizzleTable]' is missing in typeHello! I've just updated to drizzle-orm@0.29.1 and I can't use drizzle-zod anymore (@0.5.1). This Return array when parsing a schema with drizzle-valibotHello guys, I just started using drizzle-valibot and I'm not able to find in their docs nor yours hoMysql json field in where clause escaping the field namecan some one help me i am traying to create a eq(sql`${schedules.extraFields}->>'user'`, userId),, What is the best way to create conditional filters on a query?I am building an marketplace for rural real estate. I would like to build a filter system with multiCreating zod insert schema from Query with relationsI am using a Query FindFirst, with multiple relations enabled. I can infer the schema from this usin`.orderBy` influence `sql` outputWith the following code: ```ts const exchanges = await db .select({ ...getTableColumns(sDo I have to import table name type for select query?Doing this simple query: ``` dbDrizzle.select({ id: user.id }).from(user) ``` I get no inCustom SQL in migrationsTLDR: can I change the SQL in migrations or is that considered bad practice? Alright, I need some aTypeError: Cannot read properties of undefined (reading 'type') on drizzle kit push commandCan't run drizzle push:mysql on planetscale database, I'm getting this weird error: ``` + Auditors Bypass migrations when updating Planetscale schema on dev branchesHi there, Sorry, I'm a beginner in MySQL and databases, but I was wondering if there was a way to pIndex not being created in tableHi! I'm using `drizzle-kit push:pg` to update my local dev database. When I use this command, indiceDocumentation Nav menu broken on mobileI cant see the sub menus to navigate around the docs on mobileImplicit many-to-many schemaI would like to define many many-to-many relations with a more terse syntax. I have a database withMigration Confirmation/Help with PlanetScaleI know I can test this myself but I want to reduce the connections to my PlanetScale database. So,