Files
the-biergarten-app/services/BeerPost/getBeerPostById.ts
Aaron William Po 4cd2ab476f Formatting changes
2023-02-20 09:09:45 -05:00

27 lines
732 B
TypeScript

import DBClient from '@/prisma/DBClient';
import BeerPostQueryResult from './schema/BeerPostQueryResult';
const prisma = DBClient.instance;
const getBeerPostById = async (id: string) => {
const beerPost: BeerPostQueryResult | null = await prisma.beerPost.findFirst({
select: {
id: true,
name: true,
ibu: true,
abv: true,
createdAt: true,
description: true,
postedBy: { select: { username: true, id: true } },
brewery: { select: { name: true, id: true } },
type: { select: { name: true, id: true } },
beerImages: { select: { alt: true, path: true, caption: true, id: true } },
},
where: { id },
});
return beerPost;
};
export default getBeerPostById;