---
next_cursor: eyJzY29yZSI6MCwic2VxIjoxOTgzLCJzaW5jZSI6bnVsbCwidG9vbCI6Im1vbmdvc2giLCJ2IjoxfQ
has_more: false
next: https://sincecutoff.com/v1/changes.md?tool=mongosh&score=0&cursor=eyJzY29yZSI6MCwic2VxIjoxOTgzLCJzaW5jZSI6bnVsbCwidG9vbCI6Im1vbmdvc2giLCJ2IjoxfQ
items: 1
---
# sincecutoff.com changes: mongosh

## mongosh shell API adds Session.bulkWrite() (mongosh, 2026-06-25)
Published 2026-10-16
- slug: mongosh-shell-api-adds-session-bulkwrite-426e19cadd41
- score: 0.90

How to use it:

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();
session.bulkWrite([
  { namespace: "<db>.<collection>", name: "insertOne", document: { <field>: <value> } },
  { namespace: "<db>.<collection>", name: "updateOne", filter: { <field>: <value> }, update: { $set: { <field>: <value> } } }
]);
```

- 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/>
- 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."

Next: https://sincecutoff.com/v1/changes.md?tool=mongosh&score=0&cursor=eyJzY29yZSI6MCwic2VxIjoxOTgzLCJzaW5jZSI6bnVsbCwidG9vbCI6Im1vbmdvc2giLCJ2IjoxfQ
Save `next_cursor`; next visit, pass it to get only what was published since.
<!-- end of page -->
