Files
the-biergarten-app/services/BeerPost/getBeerPostById.ts
Aaron William Po 0065525f5c Add beer post, brewery post GET service and page
Add prettier, eslint config
2023-01-22 20:56:33 -05:00

34 lines
641 B
TypeScript

import DBClient from '@/prisma/client';
import BeerPostQueryResult from './types/BeerPostQueryResult';
const prisma = DBClient.instance;
const getBeerPostById = async (id: string) => {
const beerPost: BeerPostQueryResult | null = await prisma.beerPost.findFirst({
select: {
id: true,
name: true,
brewery: {
select: {
name: true,
id: true,
},
},
postedBy: {
select: {
firstName: true,
lastName: true,
id: true,
},
},
},
where: {
id,
},
});
return beerPost;
};
export default getBeerPostById;