Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

children/parent relation #15

Open
younes0 opened this issue May 31, 2022 · 2 comments
Open

children/parent relation #15

younes0 opened this issue May 31, 2022 · 2 comments

Comments

@younes0
Copy link

younes0 commented May 31, 2022

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)
@andrewmclagan
Copy link

Need more information on how you are calling the factories. But try

{
   parent: {
      create: () => ...
   }
}

@viirak
Copy link

viirak commented Sep 27, 2023

How to use the same parent for all children?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants