Update casing for services and controllers directories.

This commit is contained in:
Aaron William Po
2023-12-10 18:15:35 -05:00
parent fd641c36ab
commit 8b0d182cb3
184 changed files with 195 additions and 190 deletions

View File

@@ -0,0 +1,47 @@
import DBClient from '@/prisma/DBClient';
import { z } from 'zod';
import BeerPostQueryResult from './schema/BeerPostQueryResult';
interface GetBeerPostsByBeerStyleIdArgs {
postedById: string;
pageSize: number;
pageNum: number;
}
const getBeerPostsByPostedById = async ({
pageNum,
pageSize,
postedById,
}: GetBeerPostsByBeerStyleIdArgs): Promise<z.infer<typeof BeerPostQueryResult>[]> => {
const beers = await DBClient.instance.beerPost.findMany({
where: { postedBy: { id: postedById } },
take: pageSize,
skip: (pageNum - 1) * pageSize,
select: {
id: true,
name: true,
ibu: true,
abv: true,
createdAt: true,
updatedAt: true,
description: true,
postedBy: { select: { username: true, id: true } },
brewery: { select: { name: true, id: true } },
style: { select: { name: true, id: true, description: true } },
beerImages: {
select: {
alt: true,
path: true,
caption: true,
id: true,
createdAt: true,
updatedAt: true,
},
},
},
});
return beers;
};
export default getBeerPostsByPostedById;