mirror of
https://github.com/formbricks/formbricks.git
synced 2026-05-19 11:29:57 -05:00
c0b8edfdf2
Co-authored-by: Piyush Gupta <piyushguptaa2z123@gmail.com>
22 lines
595 B
TypeScript
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;
|
|
}
|
|
});
|