NodeJS 错误:找不到模型Prisma的Map

vu8f3i0k  于 2023-06-22  发布在  Node.js
关注(0)|答案(2)|浏览(178)

我有一些问题与后的要求和插入新的项目到棱镜表。当我发送请求时,prisma给我一个关于Map错误的错误,我找不到任何关于这个的东西,所以,我不知道如何修复它
错误:
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]应用程序崩溃-在启动前等待文件更改...
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 = "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
}

调用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})

解决方案

我做了一次模式的迁移并修复了错误,prisma说没有模式的变化,所以我相信这是postgre的同步问题

yrdbyhpb

yrdbyhpb1#

你能分享更多关于这方面的信息吗?我不能克服这个问题。

kyvafyod

kyvafyod2#

我遇到了同样的问题,当我运行生成命令时,它得到了解决。
我发现,在我的情况下,这个错误说,Prisma不知道客户端的新模型,所以在推送和生成模式后,Prisma客户端会知道新模型。

相关问题