Imagine a sale at our comic book store — one "X-Men" comic book has been sold. To update our inventory, we will decrease the stock_quantity field for "X-Men" by 1 using the $inc operator.
Here's how we do it:
The updateOne() method targets the document where title is "X-Men". The $inc operator is used to decrement the stock_quantity by 1.
Now, consider receiving a new shipment that multiplies our "Daredevil" comic book inventory by five. We can update our data using the $mul operator.
Here's the example:
The updateOne() method targets the document where title is "Daredevil". The $mul operator multiplies the stock_quantity by 5.
