Files
the-biergarten-app/services/BeerPost/getBeerPostById.ts
Aaron William Po 0b96c8f1f5 Did more work to beer post page, seed
Worked on comments and beer recs features. Fine tuning database seed amounts.
2023-01-29 21:53:05 -05:00

64 lines
1.2 KiB
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: {
beerComments: {
select: {
id: true,
content: true,
createdAt: true,
postedBy: {
select: {
username: true,
id: true,
},
},
rating: true,
},
},
id: true,
name: true,
brewery: {
select: {
name: true,
id: true,
},
},
ibu: true,
abv: true,
type: {
select: {
name: true,
id: true,
},
},
beerImages: {
select: {
alt: true,
url: true,
id: true,
},
},
createdAt: true,
description: true,
postedBy: {
select: {
username: true,
id: true,
},
},
},
where: {
id,
},
});
return beerPost;
};
export default getBeerPostById;