prisma-factory
prisma-factory copied to clipboard
children/parent relation
This parent/children schema
model Page {
id Int @id @default(autoincrement())
title String?
parentId Int?
parent Page? @relation("Parent", fields: [parentId], references: [id])
children Page[] @relation("Parent")
}
will cause the following error:
Error: missing relation dest error, model: Page, field: parent
at /projects/app/api/node_modules/prisma-factory-generator/dist/relation.js:22:19
at Array.map (<anonymous>)
at Object.getRelationFields (/projects/app/api/node_modules/prisma-factory-generator/dist/relation.js:10:8)
at Object.args (/projects/app/api/node_modules/prisma-factory-generator/dist/args.js:38:41)
at Object.addModelFactoryDeclaration (/projects/app/api/node_modules/prisma-factory-generator/dist/generator.js:159:16)
at /projects/app/api/node_modules/prisma-factory-generator/dist/index.js:97:45
at Array.forEach (<anonymous>)
at _callee$ (/projects/app/api/node_modules/prisma-factory-generator/dist/index.js:96:55)
at tryCatch (/projects/app/api/node_modules/regenerator-runtime/runtime.js:63:40)
at Generator.invoke [as _invoke] (/projects/app/api/node_modules/regenerator-runtime/runtime.js:294:22)
Need more information on how you are calling the factories. But try
{
parent: {
create: () => ...
}
}
How to use the same parent for all children?