keonik/prisma-erd-generator

Fails with the mongodb schema

xaibe opened this issue · 2 comments

xaibe commented

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

datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}

generator erd {
provider = "prisma-erd-generator"
}

model Setting {
id String @id @default(auto()) @Map("_id") @db.ObjectId
canPaySidePayment Boolean? @default(false)
canApproveSidePayment Boolean? @default(false)
fullName String @default("")
phone Int
ipAddress String
uniqueId String
adminType Int
author Admin @relation(fields: [authorId], references: [id])
authorId String

	}

model Admin {
id String @id @default(auto()) @Map("_id") @db.ObjectId
username String @default("")

loginAttemptsAt DateTime?
//relations
	settings Setting[]

}

Looks like you just need to change your @Map usage to @map

datasource db {
    provider = "mongodb"
    url      = env("DATABASE_URL")
}

generator erd {
    provider = "prisma-erd-generator"
}

model Setting {
    id                    String   @id @default(auto()) @map("_id") @db.ObjectId
    canPaySidePayment     Boolean? @default(false)
    canApproveSidePayment Boolean? @default(false)
    fullName              String   @default("")
    phone                 Int
    ipAddress             String
    uniqueId              String
    adminType             Int
    author                Admin    @relation(fields: [authorId], references: [id])
    authorId              String
}

model Admin {
    id       String @id @default(auto()) @map("_id") @db.ObjectId
    username String @default("")

    loginAttemptsAt DateTime?
    //relations
    settings        Setting[]
}
erDiagram

  Setting {
    String z_id PK 
    Boolean canPaySidePayment  "nullable"
    Boolean canApproveSidePayment  "nullable"
    String fullName  
    Int phone  
    String ipAddress  
    String uniqueId  
    Int adminType  
    }
  

  Admin {
    String z_id PK 
    String username  
    DateTime loginAttemptsAt  "nullable"
    }
  
    Setting o{--|| Admin : "author"
Loading