Answers for "$inc mongodb"

0

$inc mongodb

{
  _id: 1,
  sku: "abc123",
  quantity: 10,
  metrics: {
    orders: 2,
    ratings: 3.5
  }
}
db.products.update(
   { sku: "abc123" },
   { $inc: { quantity: -2, "metrics.orders": 1 } }
)

The updated document would resemble:

{
   "_id" : 1,
   "sku" : "abc123",
   "quantity" : 8,
   "metrics" : {
      "orders" : 3,
      "ratings" : 3.5
   }
}
Posted by: Guest on August-16-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language