Marcus
Marcus
Explore posts from servers
DTDrizzle Team
Created by Marcus on 3/6/2024 in #help
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.
workspaceId: cuid2('workspace_id')
.notNull()
.references(() => workspace.id)
workspaceId: cuid2('workspace_id')
.notNull()
.references(() => workspace.id)
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.
9 replies
DTDrizzle Team
Created by Marcus on 1/4/2024 in #help
Modeling Parent Relationships Results in TS Error
When you have a data structure like this:
export const comment = mysqlTable('crawl_item', {
id: cuid2('id').primaryKey().notNull(),
parent: cuid2('parent').references(() => comment.id),
});
export const comment = mysqlTable('crawl_item', {
id: cuid2('id').primaryKey().notNull(),
parent: cuid2('parent').references(() => comment.id),
});
You see the error:
'comment' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
'comment' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
Is there a workaround? This is blocking us unfortunately.
3 replies