Skip to content
RED SAGSkills
medium10 pts · first answer countsdatabasesmongodb

findOneAndUpdate returns the old value

This code logs the stock before the decrement, not after. Why?

const doc = await products.findOneAndUpdate(
  { _id: id },
  { $inc: { stock: -1 } }
)
console.log(doc.stock)
Choose one answer

Discussion 0

Join free to post in the discussion.

Related questions