Drizzle Typescript Init with Schema Type Error
I am testing Drizzle as an alternative to Prisma (which is our current implementation). Thanks to Drizzle's query composability it fits with some of the stuff we want to do much better.
During the process of setting up Drizzle, something is going wrong.
Looking through the docs (https://orm.drizzle.team/docs/rqb) and trying to replicate the setup is failing with a typescript error (which prevents me from accessing the
query
interface.
This is my current initialization:
schema
is imported as per the documentation:
And the schema file being referenced is generated via introspection from drizzle-kit
.
The typescript error that comes out of it is odd:
I've looked through the types, I'm not 100% sure how to correct it. As far as I can tell it's matching the documentation for query
.
Have I done something silly?3 Replies
I have made some progress by doing this:
But this isn't recommended anywhere in the documentation that I've seen.
Hello, @Trey! I think you have done everything correct.
https://orm.drizzle.team/docs/rqb#modes
When using mysql2 driver with regular MySQL database — you should specify mode: "default"
I do the same:
Drizzle ORM - next gen TypeScript ORM
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
When I added the type parameter it did complain about
mode
. If I keep the mode
params the type parameter doesn't seem necessary. Nice, ok!
Typescript led me around a little unnecessarily, but all good.