def update_product(name: str, newName: str, newPrice: float, newQuantity: int): product = Product.objects(name=name).first() product.name = newName product.price = newPrice product.quantity = newQuantity product.save()
def get_product_by_price_range(priceLowest: float, priceHighest: float) -> List[Product]: query = Product.objects() \ .filter(price__gte=priceLowest) \ .filter(price__lte=priceHighest) products = query.order_by('price') return list(products)
def remove_product(name: str): product = Product.objects(name=name).first() product.delete()
def get_product(name: str) -> Product: product = Product.objects(name=name).first() return product