Recipe Searching
- A better way for the user to look for recipes is by searching.
- We will implement the search function by building a recipe searching API that allows client to provide a q parameter to search the specific recipes by name or recipe description.
- This can be done by using the LIKE comparision operator
- The LIKE operator works by matching the search string with the target string.
- We can use % in the search string as wild card
search string | Target String | Operator | Result |
---|---|---|---|
%curry% | The Red Curry | LIKE | not match |
%curry% | The Red Curry | ILIKE | match |
red% | The Red Curry | ILIKE | not match |
%yellow% | The Red Curry | ILIKE | not match |
- To implement this functionality make changes in models/recipe.py => Recipe Model get all published to accept query
- Now in the RecipeListResource of the resources package make the changes to accomodate query and implement necessary changes in postman
- Refer Here for the changes done
Sorting and Ordering
-
Sorting is another important feature which helps user navigation.
-
Note: Try to use any cheatsheet to make your development process faster Refer Here
-
As of now we are always sorting by created date in descending order
-
Now lets implement sorting and ordering. In RecipeList -> get we will be adding sort and order. In the sort we will specify the field and in the order we will specify asc or desc
-
Refer Here for the changes done to implement sorting and ordering
-
Next Steps:
- Caching
- API Limiting