Updated replica handling. Fixed types.
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import { Prisma, Report } from '@/generated/prisma/client';
|
||||
import { Prisma } from '@/generated/prisma/client';
|
||||
import prisma from '@/lib/prisma';
|
||||
import { PageResult, QueryFilters } from '@/lib/types';
|
||||
import { QueryFilters } from '@/lib/types';
|
||||
import ReportFindManyArgs = Prisma.ReportFindManyArgs;
|
||||
|
||||
async function findReport(criteria: Prisma.ReportFindUniqueArgs): Promise<Report> {
|
||||
async function findReport(criteria: Prisma.ReportFindUniqueArgs) {
|
||||
return prisma.client.report.findUnique(criteria);
|
||||
}
|
||||
|
||||
export async function getReport(reportId: string): Promise<Report> {
|
||||
export async function getReport(reportId: string) {
|
||||
return findReport({
|
||||
where: {
|
||||
id: reportId,
|
||||
@@ -15,10 +15,7 @@ export async function getReport(reportId: string): Promise<Report> {
|
||||
});
|
||||
}
|
||||
|
||||
export async function getReports(
|
||||
criteria: ReportFindManyArgs,
|
||||
filters: QueryFilters = {},
|
||||
): Promise<PageResult<Report[]>> {
|
||||
export async function getReports(criteria: ReportFindManyArgs, filters: QueryFilters = {}) {
|
||||
const { search } = filters;
|
||||
|
||||
const where: Prisma.ReportWhereInput = {
|
||||
@@ -48,10 +45,7 @@ export async function getReports(
|
||||
return prisma.pagedQuery('report', { ...criteria, where }, filters);
|
||||
}
|
||||
|
||||
export async function getUserReports(
|
||||
userId: string,
|
||||
filters?: QueryFilters,
|
||||
): Promise<PageResult<Report[]>> {
|
||||
export async function getUserReports(userId: string, filters?: QueryFilters) {
|
||||
return getReports(
|
||||
{
|
||||
where: {
|
||||
@@ -70,10 +64,7 @@ export async function getUserReports(
|
||||
);
|
||||
}
|
||||
|
||||
export async function getWebsiteReports(
|
||||
websiteId: string,
|
||||
filters: QueryFilters = {},
|
||||
): Promise<PageResult<Report[]>> {
|
||||
export async function getWebsiteReports(websiteId: string, filters: QueryFilters = {}) {
|
||||
return getReports(
|
||||
{
|
||||
where: {
|
||||
@@ -84,14 +75,14 @@ export async function getWebsiteReports(
|
||||
);
|
||||
}
|
||||
|
||||
export async function createReport(data: Prisma.ReportUncheckedCreateInput): Promise<Report> {
|
||||
export async function createReport(data: Prisma.ReportUncheckedCreateInput) {
|
||||
return prisma.client.report.create({ data });
|
||||
}
|
||||
|
||||
export async function updateReport(reportId: string, data: any): Promise<Report> {
|
||||
export async function updateReport(reportId: string, data: any) {
|
||||
return prisma.client.report.update({ where: { id: reportId }, data });
|
||||
}
|
||||
|
||||
export async function deleteReport(reportId: string): Promise<Report> {
|
||||
export async function deleteReport(reportId: string) {
|
||||
return prisma.client.report.delete({ where: { id: reportId } });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user