Relational and sql-like query apis in the same file
Hello! My first question here. Drizzle looks really cool and I'm trying to learn it.
I have this scenario where I have my schema file like this
Then I use it in my service file
This works just fine but I also have the other kind of query type
But I don't like having to add
schema.
everytime so I specify in the import what I want exactly
This works fine but then the next stops working and it doesn't recognize it anymore
Is there a way to have both kind of queries in the same file without doing anything special?2 Replies
The key thing with the relational query builder is you need to pass the entire schema to the drizzle constructor ie
db = drizzle(driver, { schema })
In most cases that should be a nonissue since your DB instance is often created in a separate file, so you can import * there
But if for some reason you can’t do that, you could always destructure schema
Eg
Thanks, that helps a lot!