Infinite reference needs type annotation

import { integer, pgTable, serial, varchar as string } from "drizzle-orm/pg-core";

const user = pgTable("users", {
id: serial("id").primaryKey().notNull(),
name: string("name").notNull(),
badgeId: integer("badge_id").notNull().references(() => badge.id),
});

const badge = pgTable("badges", {
id: serial("id").primaryKey().notNull(),
name: string("name").notNull(),
createdBy: integer("created_by").notNull().references(() => user.id), // THIS LINE
});
import { integer, pgTable, serial, varchar as string } from "drizzle-orm/pg-core";

const user = pgTable("users", {
id: serial("id").primaryKey().notNull(),
name: string("name").notNull(),
badgeId: integer("badge_id").notNull().references(() => badge.id),
});

const badge = pgTable("badges", {
id: serial("id").primaryKey().notNull(),
name: string("name").notNull(),
createdBy: integer("created_by").notNull().references(() => user.id), // THIS LINE
});
This basic example will keep shouting because user refers to badge and badge refers to user how would you guys go about solving it?
2 Replies
Abu Somebody
Abu Somebody5mo ago
WOAH, AnyPgColumn?
Artamiel
Artamiel5mo ago
yes
Want results from more Discord servers?
Add your server