from .database import DatabaseController from models.category import Category class CategoryController(DatabaseController): FIELDS = ['id', 'name'] TYPE = Category def __init__(self): super().__init__() def create(self, category: Category): params = [ category.name, ] query = "INSERT INTO Categories (name) VALUES (?)" self.do(query, params) def read(self, id: int = 0) -> Category | None: params = [ id ] query = "SELECT * FROM Categories WHERE id = ?" return self.get_one(query, params) def read_all(self) -> list[Category] | None: query = "SELECT * FROM Categories" return self.get_many(query, []) def update(self): print("Doing work") def delete(self): print("Doing work")