diff --git a/staff/belen-ivars/project/api/logic/findRecipes.js b/staff/belen-ivars/project/api/logic/findRecipes.js new file mode 100644 index 000000000..16ea651aa --- /dev/null +++ b/staff/belen-ivars/project/api/logic/findRecipes.js @@ -0,0 +1,21 @@ +import { Recipe } from '../data/models.js' + +async function findRecipes() { + // const { diet, ingredients } = req.query + const filter = {} + if (diet) filter.diet = diet + if (method) filter.method = method + if (complexity) filter.complexity = complexity + if (time) { + filter.time = { $lte: parseInt(tiempo) } + } + if (ingredients) { + const ingredientList = ingredients.split('-') + filter.ingredients = { $in: ingredientList } + } + + + const recipes = await Recipe.find(filter) +} + +export default findRecipes \ No newline at end of file