I'm receiving error when trying to do a self referencing

I saw somewhere in this discord this self referencing coz this also receives type error too replyToId: integer("reply_to_id").references(() => Comment.id),
export const Comment = pgTable(
"comments",
{
id: serial("id").primaryKey(),
content: text("content").notNull(),
postId: integer("post_id").references(() => Post.id),
authorId: integer("author_id").references(() => Profile.id),
createdAt: timestamp("created_at").notNull().defaultNow(),
updatedAt: timestamp("updated_at").notNull().defaultNow(),
replyToId: integer("reply_to_id").references(() => Comment.id),
}}
);
export const Comment = pgTable(
"comments",
{
id: serial("id").primaryKey(),
content: text("content").notNull(),
postId: integer("post_id").references(() => Post.id),
authorId: integer("author_id").references(() => Profile.id),
createdAt: timestamp("created_at").notNull().defaultNow(),
updatedAt: timestamp("updated_at").notNull().defaultNow(),
replyToId: integer("reply_to_id").references(() => Comment.id),
}}
);
No description
2 Replies
TOSL
TOSL5d ago
@deprecated The third parameter of pgTable is changing and will only accept an array instead of an object
@example *Deprecated version:
export const users = pgTable("users", {
id: integer(),
}, (t) => ({
idx: index('custom_name').on(t.id)
}));

export const users = pgTable("users", {
id: integer(),
}, (t) => ({
idx: index('custom_name').on(t.id)
}));


New API:
export const users = pgTable("users", {
id: integer(),
}, (t) => [
index('custom_name').on(t.id)
]);

export const users = pgTable("users", {
id: integer(),
}, (t) => [
index('custom_name').on(t.id)
]);

neal
nealOP5d ago
I see thanks

Did you find this page helpful?