Files
formbricks/apps/web/modules/survey/lib/response.ts
T
2025-06-04 20:33:17 +02:00

22 lines
595 B
TypeScript

import { Prisma } from "@prisma/client";
import { cache as reactCache } from "react";
import { prisma } from "@formbricks/database";
import { DatabaseError } from "@formbricks/types/errors";
export const getResponseCountBySurveyId = reactCache(async (surveyId: string): Promise<number> => {
try {
const responseCount = await prisma.response.count({
where: {
surveyId,
},
});
return responseCount;
} catch (error) {
if (error instanceof Prisma.PrismaClientKnownRequestError) {
throw new DatabaseError(error.message);
}
throw error;
}
});