Products can now be searched using search term
This commit is contained in:
@ -51,15 +51,18 @@ class ProductController(DatabaseController):
|
||||
return products
|
||||
|
||||
|
||||
def read_all(self, category: str = "") -> list[Product] | None:
|
||||
def read_all(self, category: str = "", search_term: str = "") -> list[Product] | None:
|
||||
params = [
|
||||
"%" + category + "%"
|
||||
"%" + category + "%",
|
||||
"%" + search_term + "%"
|
||||
]
|
||||
|
||||
cursor = self._conn.execute(
|
||||
"""SELECT * FROM Products
|
||||
INNER JOIN Categories ON Products.categoryID = Categories.id
|
||||
WHERE Categories.name LIKE ? """,
|
||||
WHERE Categories.name LIKE ?
|
||||
AND Products.name LIKE ?
|
||||
""",
|
||||
params
|
||||
)
|
||||
rows = cursor.fetchall()
|
||||
|
Reference in New Issue
Block a user