Files
the-biergarten-app/services/BeerPost/getBeerRecommendations.ts
Aaron William Po 0b96c8f1f5 Did more work to beer post page, seed
Worked on comments and beer recs features. Fine tuning database seed amounts.
2023-01-29 21:53:05 -05:00

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;