Implement recipe retrieval methods and enhance inventory item types for better data handling

This commit is contained in:
Nils-Johan Gynther
2026-04-09 22:16:09 +02:00
parent 29910130f0
commit bc89e3038b
3 changed files with 52 additions and 7 deletions
+31
View File
@@ -270,4 +270,35 @@ export class RecipesService {
summary,
};
}
async findAll() {
return this.prisma.recipe.findMany({
include: {
ingredients: {
include: {
product: true,
},
},
},
});
}
async findOne(id: number) {
const recipe = await this.prisma.recipe.findUnique({
where: { id },
include: {
ingredients: {
include: {
product: true,
},
},
},
});
if (!recipe) {
throw new NotFoundException(`Recipe with id ${id} not found`);
}
return recipe;
}
}