optional parent child relationship on same table
Hi all
I have a table called 'comments'
Some comments will have a parent comment, while others will not.
The error I am getting is:
'comments' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
The code:
export const comments = pgTable('comments', {
id: uuid('id').primaryKey().defaultRandom().unique().notNull(),
parentId: uuid('parent_id').references(() => comments.id),
export const commentsRelations = relations(comments, ({ one }) => ({
parent: one(comments, {
fields: [comments.parentId],
references: [comments.id],
}),
}));
export type Comment = InferModel<typeof comments>;
I am using: pg-core0 Replies