Example #1
0
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()
Example #2
0
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)
Example #3
0
def remove_product(name: str):
    product = Product.objects(name=name).first()
    product.delete()
Example #4
0
def get_product(name: str) -> Product:
    product = Product.objects(name=name).first()
    return product