Files
the-biergarten-app/services/BeerPost/getBeerRecommendations.ts
Aaron William Po 912008e68d More work on beer image upload
patFix schema so beer image and brewery image have createdBy column. Rename 'url' to 'path' in schema, add 'caption' column.
2023-02-11 21:42:22 -05:00

22 lines
660 B
TypeScript

import DBClient from '@/prisma/DBClient';
import BeerPostQueryResult from './schema/BeerPostQueryResult';
const getBeerRecommendations = async (
beerPost: Pick<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;