Unable to Save New Record in POST Model with Prisma ORM
starlove54 opened this issue · 1 comments
Description
I'm encountering an issue when trying to add a new record to my POST
model using Prisma ORM. Despite following the usual process, the record doesn't save, and I receive an unfamiliar error which I cannot copy.
Expected Behavior
The new record should be added to the POST
model and saved correctly without any errors.
Actual Behavior
The record is not saved, and an error is shown. Unfortunately, I cannot copy the error message, but it is something I have not encountered before.
Screenshot of error
Prisma Schema
model Post{
id String @id @default(cuid()) @Map("_id")
createdAt DateTime @default(now())
slug String @unique
title String
desc String
img String?
views Int @default(0)
catSlug String
cat Category @relation(fields: [catSlug], references: [slug])
userEmail String
user User @relation(fields: [userEmail], references: [email])
comments Comment[]
}
model Category{
id String @id @default(cuid()) @Map("_id")
slug String @unique
title String
img String?
Posts Post[]
}
model User {
id String @id @default(cuid()) @Map("_id")
name String?
email String @unique
emailVerified DateTime? @Map("email_verified")
image String?
accounts Account[]
sessions Session[]
Post Post[]
Comment Comment[]
@@Map("users")
}
Additional Context
This issue occurs consistently whenever I try to save a new POST record.
I have double-checked my schema and do not see any apparent mistakes.
Possible Solution
It might be related to the relations between POST and other models.
Environment
- OS: [macos]
- Node.js version: [v20.9.0]
- Prisma version: [ 5.15.1]
- Database: [mongodb]
i solved it i was not selecting the related required record