mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-04-06 02:19:05 +00:00
Update casing for services and controllers directories.
This commit is contained in:
47
src/services/posts/beer-post/getBeerPostsByBeerStyleId.ts
Normal file
47
src/services/posts/beer-post/getBeerPostsByBeerStyleId.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import DBClient from '@/prisma/DBClient';
|
||||
import { z } from 'zod';
|
||||
import BeerPostQueryResult from './schema/BeerPostQueryResult';
|
||||
|
||||
interface GetBeerPostsByBeerStyleIdArgs {
|
||||
styleId: string;
|
||||
pageSize: number;
|
||||
pageNum: number;
|
||||
}
|
||||
|
||||
const getBeerPostsByBeerStyleId = async ({
|
||||
pageNum,
|
||||
pageSize,
|
||||
styleId,
|
||||
}: GetBeerPostsByBeerStyleIdArgs): Promise<z.infer<typeof BeerPostQueryResult>[]> => {
|
||||
const beers = await DBClient.instance.beerPost.findMany({
|
||||
where: { styleId },
|
||||
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 getBeerPostsByBeerStyleId;
|
||||
Reference in New Issue
Block a user