Reference the same table

Hello, I use drizzle with a sqlite d1 database. I have the following schema: export const authUser = sqliteTable("auth_user", { id: text("id").notNull().primaryKey(), email: text("email").notNull().unique(), firstName: text("first_name").notNull(), lastName: text("last_name").notNull(), role: text("role").notNull(), // unassigned, office, construction verified: integer("verified", { mode: "boolean" }).notNull(), manager: text("user_id").references(() => authUser.id), }); But it get the following error: typescript: 'authUser' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. How can i fix this?
3 Replies
louis
louisOP6mo ago
Also an Idea how i can "hardcode" string values? Like the role in the example
Mykhailo
Mykhailo6mo ago
Hey @Louis. You should add type AnyPgColumn
import { AnyPgColumn } from 'drizzle-orm/pg-core';

manager: text("user_id").references((): AnyPgColumn => authUser.id),
import { AnyPgColumn } from 'drizzle-orm/pg-core';

manager: text("user_id").references((): AnyPgColumn => authUser.id),
louis
louisOP5mo ago
Im using SqLite, does this still work?
Want results from more Discord servers?
Add your server