mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
Restructure codebase to use src directory
This commit is contained in:
28
src/services/BeerPost/getBeerPostById.ts
Normal file
28
src/services/BeerPost/getBeerPostById.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import DBClient from '@/prisma/DBClient';
|
||||
import beerPostQueryResult from '@/services/BeerPost/schema/BeerPostQueryResult';
|
||||
import { z } from 'zod';
|
||||
|
||||
const prisma = DBClient.instance;
|
||||
|
||||
const getBeerPostById = async (id: string) => {
|
||||
const beerPost: z.infer<typeof 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;
|
||||
Reference in New Issue
Block a user