#Next.js autocomplete with Drizzle

13 messages · Page 1 of 1 (latest)

zenith jay
#

Hi everyone!

I have a question regarding Next.js with Drizzle. I previously used Prisma, but I've seen in several places that Drizzle is faster and more efficient with queries. However, I feel like I'm doing something wrong or is it really this much of a hassle to write?

There's a lot of boilerplate initially, but my problem is that you really have to import the tables one by one for a query? And the autocomplete doesn't work with the tables, also it brings up the window (CTRL + Space) very slowly. What's even more annoying is that for a select, it doesn't suggest the column names within the table with CTRL + Space, so I have to write these out myself, which means there's no type safety.

Is something misconfigured on my end, or is this the usual way to use it?

Additionally, what I find strange is that the whole thing is quite new, but already almost every tutorial is outdated because the syntax has changed as far as I can see.
Thank you in advance!

void helmBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

molten skiff
zenith jay
#

Thanks your for your fast response!
Based on the feedback and some screenshots, do you have any tips on why the autocomplete for columns might not be working? Also, could you confirm if my queries are written correctly?
Any suggestions or corrections would be greatly appreciated!

#

If I hover over the users table in the "from(user)" part of the code, I'm seeing this:

molten skiff
#

why the autocomplete for columns might not be working?
If you mean the part:

.seclect({HERE})

That's because drizzle don't know how you want to name your return values. You should be typesafe after you entered your variable name:

.seclect({variableName: users.HERE-IS-TYPESAFE})
#

Also, could you confirm if my queries are written correctly?
You query looks good for me. However I don't know anything about so project. I like to use db.query.table.... to query specific parts of data

zenith jay
#

Actually, there's nothing special about my code. I just started following a simple tutorial where I check if the user exists during login.

For some reason, the db.query.table.... isn't working for me... it brings up what's shown in the screenshot. Even when I type in the users table, TypeScript complains that I haven't provided the database type. Is there something wrong with my config files? I also sent those in the first post.
I would be very grateful if you could take a look at them.

#

I thought what you're writing, the db.query.table, is the old syntax.

molten skiff
molten skiff
#

As you can see there is tab completion: (see attached). And also table completion for the columns: (see attached)