mirror of
https://github.com/umami-software/umami.git
synced 2026-02-13 00:55:37 +01:00
Refactored queries.
This commit is contained in:
parent
f36a689817
commit
8904b7b4ed
27 changed files with 137 additions and 144 deletions
|
|
@ -13,19 +13,29 @@ export async function getReportById(reportId: string): Promise<Report> {
|
|||
});
|
||||
}
|
||||
|
||||
export async function getReports(where: Prisma.ReportWhereInput): Promise<Report[]> {
|
||||
export async function getUserReports(userId: string): Promise<Report[]> {
|
||||
return prisma.client.report.findMany({
|
||||
where,
|
||||
where: {
|
||||
userId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getWebsiteReports(websiteId: string): Promise<Report[]> {
|
||||
return prisma.client.report.findMany({
|
||||
where: {
|
||||
websiteId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function updateReport(
|
||||
reportId: string,
|
||||
data: Prisma.ReportUpdateInput,
|
||||
where: Prisma.ReportWhereUniqueInput,
|
||||
): Promise<Report> {
|
||||
return prisma.client.report.update({ data, where });
|
||||
return prisma.client.report.update({ where: { id: reportId }, data });
|
||||
}
|
||||
|
||||
export async function deleteReport(where: Prisma.ReportWhereUniqueInput): Promise<Report> {
|
||||
return prisma.client.report.delete({ where });
|
||||
export async function deleteReport(reportId: string): Promise<Report> {
|
||||
return prisma.client.report.delete({ where: { id: reportId } });
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue