2023-05-29 06:37:34 +02:00
|
|
|
import { Prisma, Report } from '@prisma/client';
|
|
|
|
import prisma from 'lib/prisma';
|
|
|
|
|
|
|
|
export async function createReport(data: Prisma.ReportUncheckedCreateInput): Promise<Report> {
|
|
|
|
return prisma.client.report.create({ data });
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function getReportById(reportId: string): Promise<Report> {
|
|
|
|
return prisma.client.report.findUnique({
|
|
|
|
where: {
|
|
|
|
id: reportId,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-07-10 13:35:19 +02:00
|
|
|
export async function getReports(where: Prisma.ReportWhereUniqueInput): Promise<Report[]> {
|
2023-05-29 06:37:34 +02:00
|
|
|
return prisma.client.report.findMany({
|
2023-07-10 13:35:19 +02:00
|
|
|
where,
|
2023-05-29 06:37:34 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function updateReport(
|
|
|
|
data: Prisma.ReportUpdateInput,
|
|
|
|
where: Prisma.ReportWhereUniqueInput,
|
|
|
|
): Promise<Report> {
|
|
|
|
return prisma.client.report.update({ data, where });
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function deleteReport(where: Prisma.ReportWhereUniqueInput): Promise<Report> {
|
|
|
|
return prisma.client.report.delete({ where });
|
|
|
|
}
|