updateMany

noun

say it: “UP-dayt MEN-ee” /ˈʌpdeɪt ˈmɛni/

A MongoDB method that changes every document matching a filter in one call.

What does updateMany do?

updateMany changes every document that matches its filter, where updateOne changes only the first. The second argument says what to change, with an update operator such as $set, and the answer counts the matches and the changes.

db.recipes.updateMany({ cuisine: "Thai" }, { $set: { spicy: true } });
// { acknowledged: true, matchedCount: 7, modifiedCount: 7, ... }

In a sentence

  • “One updateMany marked all seven Thai recipes as spicy.”
  • “Check the filter with find first, because updateMany changes everything it matches.”

Level: Apprentice · More MongoDB terms at this level

Updated