Files
the-biergarten-app/services/BreweryPost/getBreweryPostById.ts
Aaron William Po b69dbc95b4 Work on brewery page, refactors
Refactor query types to explicitly use z.infer
2023-03-31 21:13:35 -04:00

24 lines
679 B
TypeScript

import DBClient from '@/prisma/DBClient';
import BreweryPostQueryResult from '@/services/BreweryPost/types/BreweryPostQueryResult';
import { z } from 'zod';
const prisma = DBClient.instance;
const getBreweryPostById = async (id: string) => {
const breweryPost: z.infer<typeof BreweryPostQueryResult> | null =
await prisma.breweryPost.findFirst({
select: {
id: true,
location: true,
name: true,
breweryImages: { select: { path: true, caption: true, id: true, alt: true } },
postedBy: { select: { username: true, id: true } },
},
where: { id },
});
return breweryPost;
};
export default getBreweryPostById;