简体   繁体   English

创建记录时 Prisma typescript 类型错误

[英]Prisma typescript type error when creating record

I 'm using prisma with MySql.我正在使用带有 MySql 的棱镜。 When I try to create a new record (School) I get a type error in console.当我尝试创建新记录(学校)时,控制台中出现类型错误。 I'm using a framework called Remix.run too, but it shouldn't be the problem.我也在使用一个名为 Remix.run 的框架,但这应该不是问题。

I've tried using mongoDB too, but i got the same type error.我也尝试过使用 mongoDB,但我得到了相同的类型错误。

Error错误

251 console.log(info);
252 });
253 let data = {school_code: key, otp: code};
→ 254 await db.schools.create({
    data: {
        school_code: 'ISP0TMORECNJS9TB',
        ~~~~~~~~~~~
        otp: 'EMI5DU'
    }
})

Unknown arg `school_code` in data.school_code
for type schoolsCreateInput.Available args:

    type schoolsCreateInput {
        id ? : String
        v ? : Int | Null
        otp: String
    }

Prisma schema棱镜模式

datasource db {
    provider = "mysql"
    url = "mysql://root@localhost:3306/myeducatio"
}

model schools {
    otp String @db.Text
    school_code String @id
}

Code代码

Method 1方法一

let data: any = {
    school_code: key,
    otp: code
};

await db.schools.create({
    data,
});

Method 2方法二

await db.schools.create({
    data: {
        school_code: key,
        otp: code
    }
});

Found out I had installed prisma outside my project folder.发现我已经在我的项目文件夹之外安装了 prisma。 I just deleted it and reinstalled it.我刚刚删除它并重新安装它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM