def get_all_products(self) -> [ProductDalModel]: """ Retrieves all products from the database and converts to DAL model :return: A list of all products """ products = Product.select() dal_models = [ProductDalModel.create_from_model(p) for p in products] return dal_models
def get_all_orders(self) -> List[OrderDalModel]: """ Get all orders in the database :return: A list of all orders in the database """ orders = Order.select() product_orders = (ProductOrder.select()) order_models = orders.prefetch(product_orders, (Product.select())) dal_models = [OrderDalModel.create_from_model(m) for m in order_models] return dal_models