mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
Restructure codebase to use src directory
This commit is contained in:
22
src/services/BeerPost/getBeerRecommendations.ts
Normal file
22
src/services/BeerPost/getBeerRecommendations.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import DBClient from '@/prisma/DBClient';
|
||||
import beerPostQueryResult from '@/services/BeerPost/schema/BeerPostQueryResult';
|
||||
import { z } from 'zod';
|
||||
|
||||
const getBeerRecommendations = async (
|
||||
beerPost: Pick<z.infer<typeof beerPostQueryResult>, 'type' | 'brewery' | 'id'>,
|
||||
) => {
|
||||
const beerRecommendations = await DBClient.instance.beerPost.findMany({
|
||||
where: {
|
||||
OR: [{ typeId: beerPost.type.id }, { breweryId: beerPost.brewery.id }],
|
||||
NOT: { id: beerPost.id },
|
||||
},
|
||||
include: {
|
||||
beerImages: { select: { id: true, path: true, caption: true, alt: true } },
|
||||
brewery: { select: { id: true, name: true } },
|
||||
},
|
||||
});
|
||||
|
||||
return beerRecommendations;
|
||||
};
|
||||
|
||||
export default getBeerRecommendations;
|
||||
Reference in New Issue
Block a user