db.query throwing undefined is not an object (evaluating 'relation.referencedTable')
Hi, so i have this schema called
product.ts
and it's related to category with one-to-many relationship
But when i try to do query findMany, it throws an error
The error like in the image.
Thank you!![No description](https://cdn.answeroverflow.com/1219061433048891442/image.png)
5 Replies
Hello, @NyxSR! Could you please show how do you initialize db? You might forget to pass
schema
parameter.
https://orm.drizzle.team/docs/rqbDrizzle ORM - Query
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
![No description](https://cdn.answeroverflow.com/1219256619121119313/image.png)
So i've created a file called
db.ts
and for the schema value inside db variables is from this. what inside
index.ts
from db/schema is just a simple file
![No description](https://cdn.answeroverflow.com/1219291106337099776/image.png)
@NyxSR you have to update your exports because you need relations too and then you can import from your schema/index
Ahh i see, let me try that
Thanks a lot @Mykhailo , that works !