feat: add beer style comments

This commit is contained in:
Aaron William Po
2023-10-15 20:24:40 -04:00
parent 27af922a91
commit c8e8207e30
16 changed files with 774 additions and 26 deletions

View File

@@ -0,0 +1,32 @@
import DBClient from '@/prisma/DBClient';
import { z } from 'zod';
import CommentQueryResult from '../schema/CommentSchema/CommentQueryResult';
interface GetAllBeerStyleCommentArgs {
beerStyleId: string;
pageNum: number;
pageSize: number;
}
const getAllBeerStyleComments = async ({
beerStyleId,
pageNum,
pageSize,
}: GetAllBeerStyleCommentArgs): Promise<z.infer<typeof CommentQueryResult>[]> => {
return DBClient.instance.beerStyleComment.findMany({
skip: (pageNum - 1) * pageSize,
take: pageSize,
where: { beerStyleId },
orderBy: { createdAt: 'desc' },
select: {
id: true,
content: true,
rating: true,
createdAt: true,
updatedAt: true,
postedBy: { select: { id: true, username: true, createdAt: true } },
},
});
};
export default getAllBeerStyleComments;