I'm having some problems with a post request and inserting new items into a prisma table. When i send the request, the prisma gives me an error about some error with Mapping, and i won't find anything talking about that , so , i don't know how i can fix it
Error:
C:\GitHub\Project\BackEnd\node_modules@prisma\client\runtime\index.js:30904 throw new Error(
Could not find mapping for model ${model}); ^ Error: Could not find mapping for model Product at PrismaClient._executeRequest (C:\GitHub\Project\BackEnd\node_modules@prisma\client\runtime\index.js:30904:17) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async PrismaClient._request (C:\GitHub\Project\BackEnd\node_modules@prisma\client\runtime\index.js:30864:16) at async createNew(C:\GitHub\Project\BackEnd\src\Controller\ProdutoController.ts:20:25) { clientVersion: '4.3.1' } [nodemon] app crashed - waiting for file changes before starting...
Prisma Schema:
// 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 = "postgresql"
url = env("DATABASE_URL")
}
model Product{
id Int @id @default(autoincrement())
name String
description String
createDate String
datePublish DateTime @default(now())
type String
value Float
height String
width String
length String
material String
category String
}
function who call prisma create
async createNew (req: Request, res: Response){
const {
name,
description ,
createDate,
datePublish ,
type,
value,
height,
width,
length,
material,
category
} = req.body
const product = await prisma.product.create({
data:{
name,
description ,
createDate,
datePublish ,
type,
value,
height,
width,
length,
material ,
category
},
})
return res.json({product})
SOLUTION
I do the migration of schema again and fix the error, prisma said that there were no schema changes, so I believe it was a sync problem with postgre