mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
patFix schema so beer image and brewery image have createdBy column. Rename 'url' to 'path' in schema, add 'caption' column.
65 lines
1.2 KiB
TypeScript
65 lines
1.2 KiB
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: {
|
|
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,
|
|
path: true,
|
|
caption: true,
|
|
id: true,
|
|
},
|
|
},
|
|
createdAt: true,
|
|
description: true,
|
|
postedBy: {
|
|
select: {
|
|
username: true,
|
|
id: true,
|
|
},
|
|
},
|
|
},
|
|
where: {
|
|
id,
|
|
},
|
|
});
|
|
|
|
return beerPost;
|
|
};
|
|
|
|
export default getBeerPostById;
|