Added report context. Removed report store.

This commit is contained in:
Mike Cao committed 2023-05-28 21:37:34 -07:00
1 parent bc37f5124e
commit bfb52eb678
31 files changed
+372 -273

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
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,
},
});
}
export async function getReports(userId: string): Promise<Report[]> {
return prisma.client.report.findMany({
where: {
userId,
},
});
}
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 });
}