mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-04-05 18:09:04 +00:00
feat: add beer style comments
This commit is contained in:
32
src/services/BeerStyleComment/getAllBeerStyleComments.ts
Normal file
32
src/services/BeerStyleComment/getAllBeerStyleComments.ts
Normal 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;
|
||||
Reference in New Issue
Block a user