{
  "slug": "mongosh-shell-api-adds-session-bulkwrite-426e19cadd41",
  "title": "mongosh shell API adds Session.bulkWrite()",
  "tools": [
    "mongosh"
  ],
  "tags": [
    "agent"
  ],
  "introduced_at": "2026-06-25T18:14:57.000Z",
  "announced_at": "2026-06-25T18:14:57.000Z",
  "effective_at": null,
  "date_basis": "source-publication",
  "status": "unknown",
  "how": {
    "incantation": "When repository code needs to submit multiple MongoDB writes through a session, call `Session.bulkWrite(operations, options)` with an array of write-operation documents. The operation requires MongoDB 8.0 or later.",
    "examples": [
      "const session = db.getMongo().startSession();\nsession.bulkWrite([\n  { namespace: \"<db>.<collection>\", name: \"insertOne\", document: { <field>: <value> } },\n  { namespace: \"<db>.<collection>\", name: \"updateOne\", filter: { <field>: <value> }, update: { $set: { <field>: <value> } } }\n]);"
    ],
    "gotchas": [
      "Version: v2.9.0",
      "operations (required): Array of write-operation documents. Each specifies a namespace, operation name, and operation-specific fields. Supported operations: insertOne, replaceOne, updateOne, updateMany, deleteOne, deleteMany.",
      "options: Options document; all documented sub-keys are optional: `ordered` (default true; stop at first error when true), `verboseResults` (default false), `bypassDocumentValidation` (default false), and `let` (document of values available as aggregation variables). No mutual exclusions are documented.",
      "namespace (required): Operation document key: database and collection for the write, in `<db>.<collection>` form.",
      "name (required): Operation document key: operation name, such as `insertOne` or `updateOne`.",
      "document (required): For `insertOne`, the document to insert.",
      "filter (required): For update, replace, and delete operations, the document selector for matching documents.",
      "update (required): For `updateOne` or `updateMany`, the update document or array of update documents.",
      "Prerequisite: Use a MongoDB 8.0 or later deployment. Create the session with `db.getMongo().startSession()` before calling the method."
    ]
  },
  "why_it_matters": "When implementing repository code that needs to submit multiple MongoDB writes through a mongosh session, use the shell API bulk write method.",
  "sources": [
    "https://github.com/mongodb-js/mongosh/releases/tag/v2.9.0",
    "https://www.mongodb.com/docs/v8.0/reference/method/mongo.bulkwrite/",
    "https://www.mongodb.com/docs/manual/reference/method/session/"
  ],
  "rank": 0.90016,
  "judge": {
    "publish": true,
    "judge_model": "codex-cli/gpt-6-luna+typesafe/jev-1.13.0",
    "prompt_version": "extract-v7+enrich-v2+judge-v2x3+jev-publish-v1"
  },
  "review_state": "approved",
  "provenance": {
    "run_id": "wave1-20261014",
    "verdict_id": "wave1-20261014:wave1-20261014-f43017949d0ccd04-0:gate",
    "evidence_hash": "e1602c6b0680184af27a9b9f9802e805c1cb9f6c70df11d6c2c5157b976eee6f"
  },
  "review": {
    "draft_hash": "f16156231433e15fbdc833e162e145ab5eccda1f08e0b97d99e159e942a3fea1",
    "reviewer": "publication-gate",
    "reviewed_at": "2026-10-07T00:00:00.000Z",
    "decision": "wave1-20261014:gate",
    "reason": "2 of 3 judge runs approved with p_yes >= 0.9 (mean 0.90 >= 0.9; 2 needed) and Jev gave 0.69 (>= 0.6 needed)."
  }
}
