Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I'm working on ReactJS project with NextJS Framework and Prisma to manage connection and queries to the DB.
On my local project the
Support
model is found and when I use it in my API and build my project it's ok.
But when I push my project on production server (Plesk), the build shows me this typescript error because it doesn't find the
Support
model:
./src/pages/api/support/index.ts:27:26
Type error: Property 'support' does not exist on type 'PrismaClient<PrismaClientOptions, never, RejectOnNotFound | RejectPerOperation | undefined>'.
The path ./src/pages/api/support/index.ts
is where I want to use the Support model
My prisma.schema
:
datasource db {
provider = "mysql"
url = env("DATABASE_CONNECTION")
generator client {
provider = "prisma-client-js"
model User {
id Int @id @unique @default(autoincrement())
gender String?
firstName String
lastName String
email String @unique
phone String
birthday DateTime?
income Float?
pincode Int?
points Float?
token String @db.Text
ipAddress String
kyc Kyc[]
createdAt DateTime @default(now())
updatedAt DateTime?
isValidated Boolean @default(false)
roleId Int
role Role @relation(fields: [roleId], references: [id])
Alerts Alerts[]
Support Support[]
model Kyc {
id Int @id @unique @default(autoincrement())
name String
validated Boolean @default(false)
path String
createdAt DateTime @default(now())
updatedAt DateTime? @updatedAt
user User @relation(fields: [userId], references: [id])
userId Int
model Alerts {
id Int @id @unique @default(autoincrement())
type TYPE @default(NOBLOCKED)
message String @db.Text
transferId Int @unique
fromUserId Int
read Boolean @default(false)
createdAt DateTime @default(now())
user User @relation(fields: [fromUserId], references: [id])
model Role {
id Int @id @unique @default(autoincrement())
name String
User User[]
model Support {
id Int @id @unique @default(autoincrement())
subject String
message String @db.Text
createdAt DateTime @default(now())
userId Int
user User @relation(fields: [userId], references: [id])
enum TYPE {
BLOCKED
NOBLOCKED
I don't know if I need to use prisma migrate dev
or prisma migrate deploy
each time I push the latest changes.
–
–
–
–
–
–
My issue was that the prisma client references the model names but as camelCase, whereas they're defined in the schema using PascalCase. This threw me because most of my model names are single words so where I'd defined a model name like User
in the schema and added @@map("user")
to the definition, I had the impression that when I did something like await prisma.user.delete({ ...
the model/ table name user
was lowercase as a result of the @@map
declaration, but it turns out it isn't, rather prisma takes the model name and makes the first letter lowercase, and hence why for my model name OTP
(with @@map("otp)
) I have to use it like prisma.oTP.delete({ ...
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.