mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-12 20:47:38 +01:00
34 lines
880 B
TypeScript
34 lines
880 B
TypeScript
|
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 });
|
||
|
}
|