mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 18:52:06 +00:00
Did more work to beer post page, seed
Worked on comments and beer recs features. Fine tuning database seed amounts.
This commit is contained in:
31
services/BeerPost/getBeerRecommendations.ts
Normal file
31
services/BeerPost/getBeerRecommendations.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user