Files
the-biergarten-app/services/BeerPost/getBeerPostById.ts
2023-01-22 23:49:58 -05:00

35 lines
668 B
TypeScript

import DBClient from '@/prisma/DBClient';
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,
},
},
description: true,
postedBy: {
select: {
firstName: true,
lastName: true,
id: true,
},
},
},
where: {
id,
},
});
return beerPost;
};
export default getBeerPostById;