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

Prisma Generate: MongoDB throws related model not found when using Types #132

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

Comments

@nalham
Copy link

nalham commented May 31, 2022

In this scenario, I have a nested Document type that isn't a database indexed item.

Let's use Foo and Oof both needing access to the type of Bar.

file: schema.prisma

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "mongodb"
  url      = "{urlOmitted}"
}

generator nestjsDto {
  provider                        = "prisma-generator-nestjs-dto"
  output                          = "../src"
  outputToNestJsResourceStructure = "true"
}

type Bar {
  thing1 String
  thing2 Int
  thing3 Boolean
}

model Foo {
  id            String          @id @default(auto()) @map("_id") @db.ObjectId
  bar          Bar
  thing       Int
}

model Oof {
  id            String          @id @default(auto()) @map("_id") @db.ObjectId
  bar          Bar
  thing      String
}

Upon generation, an error is thrown Error: related model 'Bar' for 'Foo.bar' not found

npx prisma generate
Prisma schema loaded from prisma/schema.prisma
prisma:info Processing Model Foo
Error:
✔ Generated Prisma Client (3.14.0 | library) to ./node_modules/@prisma/client in 74ms

Error: related model 'Bar' for 'Foo.bar' not found
@eliasblume
Copy link

I have the same issue. I guess this is just not supported with the current version...
Any chance that this will be added?

@gwesterman
Copy link

Can't use this library or any of the current forks I found until this is resolved.

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

No branches or pull requests

3 participants