HighTouch
HighTouch
DTDrizzle Team
Created by HighTouch on 6/19/2024 in #help
Not enough information to infer relation with self-one-To-Many relation
Sorry my research on the discord didn't show me this thread which explains what my mistake was: https://discord.com/channels/1043890932593987624/1173896750663213066/1173896750663213066 the mistake was that both relation names should be the same so in my schema i should have:
export const questionsRelations = relations(questionSchema, ({ many, one }) => ({
parentQuestion: one(questionSchema, {
fields: [questionSchema.parentQuestion],
references: [questionSchema.id],
relationName: 'parentQuestion',
}),
subQuestions: many(questionSchema, {
relationName: 'parentQuestion', // <========== notice parentQuestion instead of subquestions
}),
}))
export const questionsRelations = relations(questionSchema, ({ many, one }) => ({
parentQuestion: one(questionSchema, {
fields: [questionSchema.parentQuestion],
references: [questionSchema.id],
relationName: 'parentQuestion',
}),
subQuestions: many(questionSchema, {
relationName: 'parentQuestion', // <========== notice parentQuestion instead of subquestions
}),
}))
3 replies