Recursive table references declaration #775
Answered
by
nlynzaad
tronikelis
asked this question in
Q&A
-
My schema: export const comments = pgTable("comments", {
id: serial("id").primaryKey(),
body: text("body").notNull(),
userId: integer("user_id")
.references(() => users.id, { onDelete: "set null" })
.notNull(),
parentId: integer("parent_id").references(() => /** ??? comments.id */ {}),
}); Is there no way to add a reference to self currently? |
Beta Was this translation helpful? Give feedback.
Answered by
nlynzaad
Jul 2, 2023
Replies: 1 comment
-
came across this question looking for a whole other answer but remembered seeing something in the docs. maybe it can help: Take a look at the second example it speaks specifically to self referencing. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
tronikelis
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
came across this question looking for a whole other answer but remembered seeing something in the docs. maybe it can help:
Take a look at the second example it speaks specifically to self referencing.
Foreign Keys