Circular Dependency Hell
Is it just me or does using the relations API result in a bunch of circular deps that aren't lazily instantiated. For example, a foreign key reference is a function.
For relations, it's something like this:
workspace: one(workspace),
.
I feel like everything needs to be lazily instantiated because I'm eating alive by: Cannot read properties of undefined (reading 'Symbol(drizzle:Name)')
. I've spent 20-30 hours fighting it and I think I'm just going to delete the relations API although even though I like the DX.6 Replies
I guess it's just me, sad!
Oh, I think you need to alias the workspace and then reference it.
For example if the table is called
workspaces
you can do this:
I remember seeing this in the old docs.Oh, found this in the new docs:
This should probably fix your problem.
Drizzle ORM - Indexes & Constraints
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
I have that for types on a self referencing type. My issue is a runtime error when two different models reference each other. Since there no closure on relations the value is undefined since it’s hoisted to the top on compilation