mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
32 lines
715 B
TypeScript
32 lines
715 B
TypeScript
import BeerPostQueryResult from '@/services/BeerPost/types/BeerPostQueryResult';
|
|
import DBClient from '@/prisma/DBClient';
|
|
|
|
const getBeerRecommendations = async (
|
|
beerPost: Pick<BeerPostQueryResult, 'type' | 'brewery'>,
|
|
) => {
|
|
const beerRecommendations = await DBClient.instance.beerPost.findMany({
|
|
where: {
|
|
OR: [
|
|
{
|
|
typeId: beerPost.type.id,
|
|
},
|
|
{
|
|
breweryId: beerPost.brewery.id,
|
|
},
|
|
],
|
|
},
|
|
include: {
|
|
beerImages: {
|
|
select: { id: true, url: true, alt: true },
|
|
},
|
|
brewery: {
|
|
select: { id: true, name: true },
|
|
},
|
|
},
|
|
});
|
|
|
|
return beerRecommendations;
|
|
};
|
|
|
|
export default getBeerRecommendations;
|