admin管理员组文章数量:1123048
I am getting error during build time:
My prisma database schema code is pasted below:
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
enum ReportStatus {
PENDING
IN_PROGRESS
RESOLVED
DISMISSED
}
enum ReportType {
EMERGENCY
NON_EMERGENCY
}
enum Role {
ADMIN
MODERATOR
USER
}
model Report {
id String @id @default(cuid())
reportId String @unique
type ReportType
title String
description String
reportType String
location String?
latitude String?
longitude String?
image String?
status ReportStatus @default(PENDING)
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
@@index([reportId])
}
model User {
id Int @id @default(autoincrement())
email String @unique
name String
password String
role Role @default(USER)
}
And the code for app/api/reports/create/route.ts pasted below:
import { NextResponse } from "next/server";
import db from "@/lib/prisma";
import { ReportType } from "@prisma/client";
export async function POST(request:Request) {
try {
const {
reportId,
type,
specificType,
title,
description,
location,
latitude,
longitude,
image,
status,
} = await request.json();
const report = await db.report.create({
data: {
reportId,
type: type as ReportType,
title,
description,
reportType: specificType,
location,
latitude: latitude || null,
longitude: longitude || null,
image: image || null,
status: status || "PENDING",
},
});
return NextResponse.json({
success: true,
reportId: report.reportId,
message: "Report submitted successfully",
});
} catch (error) {
console.error("Error creating report:", error);
return NextResponse.json(
{
success: false,
error: "Failed to submit report",
},
{ status: 500 }
);
}
}
How to resolve the issue??
Don't understand what's the actual error, this is my first time working with prisma. Is the schema declared in a wrong way or any other mistake I made in the code, help me to find it out.
版权声明:本文标题:typescript - Type error: Module '"@prismaclient"' has no exported member 'ReportType&a 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736542837a1944407.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论