collMod

noun

say it: “KOL-mod” /ˈkɑlˌmɑd/

A MongoDB command that changes the settings of a collection that already exists, such as its validation rules.

What does the collMod command do?

collMod is the command that changes the settings of a collection that already exists, such as adding or replacing its validator. You run it through db.runCommand, naming the collection.

db.runCommand({
  collMod: "products",
  validator: { $jsonSchema: { required: ["name", "price"] } }
});
// { ok: 1 }

In a sentence

  • “A collMod with validationAction warn let the team see which old documents broke the rules.”
  • “The products collection already held data, so its new rules went on with collMod.”

Level: Freelancer · More MongoDB terms at this level

Updated