From f20a74266797c69a94bd78f0e2374803b1135615 Mon Sep 17 00:00:00 2001 From: Rayhan Hassou Date: Wed, 6 Dec 2023 10:09:09 +0100 Subject: [PATCH] modify filter route --- API-Project/src/gateways/ingredients.gateway.ts | 4 ++-- API-Project/src/gateways/recipe.gateway.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/API-Project/src/gateways/ingredients.gateway.ts b/API-Project/src/gateways/ingredients.gateway.ts index 76c6ba6..cd476cf 100644 --- a/API-Project/src/gateways/ingredients.gateway.ts +++ b/API-Project/src/gateways/ingredients.gateway.ts @@ -74,7 +74,7 @@ export class IngredientsGateway { const client = await this.connection.getPoolClient() const query = { - text: 'SELECT * FROM Ingredients i WHERE LOWER(SUBSTRING(i.name, 1, 1)) = $1', + text: 'SELECT * FROM Ingredients i WHERE LOWER(SUBSTRING(i.name, 1, 1)) = $1 ORDER BY i.name', values: [letter.toLowerCase()], }; @@ -100,7 +100,7 @@ export class IngredientsGateway { const client = await this.connection.getPoolClient() const query = { - text: 'SELECT * FROM Ingredients WHERE LOWER(name) LIKE $1', + text: 'SELECT * FROM Ingredients WHERE LOWER(name) LIKE $1 ORDER BY name', values: [`%${prompt.toLowerCase()}%`], }; diff --git a/API-Project/src/gateways/recipe.gateway.ts b/API-Project/src/gateways/recipe.gateway.ts index 779f22f..68e7a08 100644 --- a/API-Project/src/gateways/recipe.gateway.ts +++ b/API-Project/src/gateways/recipe.gateway.ts @@ -29,7 +29,7 @@ export class RecipeGateway { recipes.push(recipe); } - return recipes + return recipes as Recipe[]; } async getById(id: number) : Promise{ @@ -86,6 +86,6 @@ export class RecipeGateway { } } - return recipes + return recipes as Recipe[]; } } \ No newline at end of file