app/modules/products/services.py
def update(self, db: Session, id: int, product: ProductUpdate) -> ProductResponse:
        """
        Edits a product by id.

        Args:
            db (Session): The database session.
            id (int): The product ID.
            product (ProductUpdate): The product update model.

        Returns:
            ProductResponse: The Product Response model.
        """        
        original_product = db.query(Product).filter(and_(
            Product.id == id,
            Product.is_deleted == False
        )).first()
        if not original_product:
            return None

        original_product.update(db, **product.dict(exclude_unset=True))
        new_product = ProductResponse.from_orm(original_product)
        return new_product

        Edits a product by id.

        Args:
            db (Session): The database session.
            id (int): The product ID.
            product (ProductUpdate): The product update model.

        Returns:
            ProductResponse: The Product Response model.
        
Edits a product by id.
Edits a product by id .
def update(self, db: Session, id: int, product: ProductUpdate) -> ProductResponse:
        original_product = db.query(Product).filter(and_(
            Product.id == id,
            Product.is_deleted == False
        )).first()
        if not original_product:
            return None
        original_product.update(db, **product.dict(exclude_unset=True))
        new_product = ProductResponse.from_orm(original_product)
        return new_product
def update ( self , db : Session , id : int , product : ProductUpdate ) -> ProductResponse : original_product = db . query ( Product ) . filter ( and_ ( Product . id == id , Product . is_deleted == False ) ) . first ( ) if not original_product : return None original_product . update ( db , ** product . dict ( exclude_unset = True ) ) new_product = ProductResponse . from_orm ( original_product ) return new_product
Edits a product by id.
Edits a product by id .
"""
        Edits a product by id.

        Args:
            db (Session): The database session.
            id (int): The product ID.
            product (ProductUpdate): The product update model.

        Returns:
            ProductResponse: The Product Response model.
        """
The Product Response model.
The Product Response model .
ProductResponse
self
db
Session
The database session.
The database session .
id
int
The product ID.
The product ID .
product
ProductUpdate
The product update model.
The product update model .