node-mongodb-native
AGENTS.md10k starsChanged 7 months agoApache-2.0View on GitHub
This is the official MongoDB Node.js driver (mongodb npm package). It provides a TypeScript/JavaScript interface for applications to interact with MongoDB deployments. The driver implements the cross-driver MongoDB specifications. Do not hand-edit: lib/ (build output), mongodb.d.ts (generated), HISTORY.md (release-please managed), test/spec/ (vendored from specifications repo). Integration tests require a running MongoDB instance (unit tests do not). To start one locally: Tests use Mocha with 60-second timeout. Integration tests use a custom metadata UI that supports test filtering by topology, MongoDB…
Trending
Less talk lately.about the whole repository
Who's talking about mongodb/node-mongodb-native
- loopbackio/loopback-connector-mongodb“DeprecationWarning: current URL string parser is deprecated”GitHub · Jun 27, 2018 · 40 reactions
- meteor/meteor“Oplog tailing stalls (usually during MongoDB failover) (maybe primarily with Compose Classic)”GitHub · Apr 13, 2017 · 22 reactions
- Automattic/mongoose“DeprecationWarning: Listening to events on the Db class has been deprecated and will be removed in the next …”GitHub · Feb 14, 2021 · 20 reactions
- shelfio/jest-mongodb“Upgrade dependencies for mongodb@6 and higher”GitHub · Oct 4, 2023 · 19 reactions
- loopbackio/loopback-connector-mongodb“Package `mongodb` updated to version `2.2.23`”GitHub · Feb 13, 2017 · 10 reactions
The biggest 5 of 27 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 27
Talked about on GitHub and Hacker News (27 times).
On GitHub · 24
- Jun 27, 2018DeprecationWarning: current URL string parser is deprecated — loopbackio/loopback-connector-mongodb40 reactions · 14 comments
- Apr 13, 2017Oplog tailing stalls (usually during MongoDB failover) (maybe primarily with Compose Classic) — meteor/meteor22 reactions · 33 comments
- Feb 14, 2021DeprecationWarning: Listening to events on the Db class has been deprecated and will be removed in the next major version — Automattic/mongoose20 reactions · 13 comments
- Oct 4, 2023Upgrade dependencies for mongodb@6 and higher — shelfio/jest-mongodb19 reactions · 4 comments
- Feb 13, 2017Package `mongodb` updated to version `2.2.23` — loopbackio/loopback-connector-mongodb10 reactions · 7 comments
19 more on GitHub
- Feb 1, 2018Replace Cursor.nextObject because it was removed from node-mongodb-native library — aheckmann/gridfs-stream8 reactions · 9 comments
- May 13, 2020node 14 circular dependency with mongodb driver — Automattic/monk7 reactions · 2 comments
- Apr 1, 2018Update MongoDB driver to 3.0.5 — meteor/meteor7 reactions · 5 comments
- Jun 9, 2025OPLog tailing in Meteor 3.1 and 3.2 results in infinite number of cursors in Mongo database server — meteor/meteor5 reactions · 7 comments
- Aug 17, 2021mongodb driver 4.x support for Mongo Altas Serverless — loopbackio/loopback-connector-mongodb4 reactions · 6 comments
- Jul 15, 2021feat: update mongodb to major version 4 — typeorm/typeorm4 reactions · 14 comments
- Apr 7, 2019APM for "serialize command" step — mongodb-js/mongodb-core4 reactions · 8 comments
- Mar 17, 2018Find exercise: connect callback parameters have changed in current version — evanlucas/learnyoumongo4 reactions · 8 comments
- May 2, 2016Update to Mongo 3.2 — meteor/meteor4 reactions · 59 comments
- Aug 20, 2019default to using useUnifiedTopology option — Automattic/monk3 reactions · 6 comments
- Jul 10, 2018Unhandled duplicate key errors with Meteor 1.7 — meteor/meteor-synced-cron3 reactions · 4 comments
- Oct 5, 2026chore(deps): bump the databases group across 1 directory with 12 updates — DataDog/dd-trace-js2 reactions · 5 comments
- Jun 22, 2026build(deps): bump the production group across 1 directory with 24 updates — thanhan92-f1/hitechclaw2 reactions · 1 comment
- Jun 15, 2026deps(deps): bump the security-updates group with 12 updates — koushik369mondal/WanderLust2 reactions · 3 comments
- Jun 8, 2026build(deps): bump the production group across 1 directory with 25 updates — thanhan92-f1/hitechclaw2 reactions · 1 comment
- Jun 2, 2026build(deps): bump the production group across 1 directory with 23 updates — thanhan92-f1/hitechclaw2 reactions · 2 comments
- May 25, 2026build(deps): bump the production group across 1 directory with 21 updates — thanhan92-f1/hitechclaw2 reactions · 2 comments
- Mar 23, 2026Unable to use SOCKS proxy with Entra ID / OIDC authentication: missing 'socks' dependency for MongoDB connection — microsoft/vscode-documentdb2 reactions · 1 comment
- Sep 19, 2022refactor: use promise API — fastify/fastify-mongodb2 reactions · 1 comment
On Hacker News · 3
- Oct 25, 2013Why there is no issues tab at MongoDB NodeJS package at GitHub?2 points · 1 comment
- Oct 25, 2013GitHub issues removed from nodejs mongodb driver2 points
- Apr 26, 2012Mongodb/node-mongodb-native2 points
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
The file
We split this AGENTS.md into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 120
Follow Conventional Commits: <type>(NODE-XXXX): <subject>
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
This file provides guidance to AI coding agents (Claude Code, Codex, Copilot, Cursor, Aider, etc.) when working with code in this repository.
Project Overview
This is the official MongoDB Node.js driver (mongodb npm package). It provides a TypeScript/JavaScript interface for applications to interact with MongoDB deployments. The driver implements the cross-driver MongoDB specifications.
Related Repositories
- mongodb/specifications — Cross-driver MongoDB specifications. This is the source of truth for behavior the driver must implement (CRUD, SDAM, CMAP, retryable reads/writes, sessions, transactions, change streams, CSFLE, etc.). Spec test fixtures (YAML/JSON) are vendored under
test/spec/. When behavior is ambiguous, the spec wins; do not change behavior away from the spec without raising it there first. - mongodb/js-bson — BSON serialization (
bsonnpm package). Owned by this team. Bug reports and changes that touch BSON encoding/decoding belong there. - mongodb-js/kerberos — Native Kerberos bindings (
kerberosnpm package, optional dependency). Owned by this team. GSSAPI auth issues are typically fixed there, not in the driver. - mongodb-js/mongodb-client-encryption — Native bindings to
libmongocryptfor CSFLE/Queryable Encryption (mongodb-client-encryptionnpm package). Owned by this team. - mongodb-js/zstd and mongodb-js/saslprep — Compression and SCRAM SASLprep helpers, also team-owned.
Do not hand-edit: lib/ (build output), mongodb.d.ts (generated), HISTORY.md (release-please managed), test/spec/ (vendored from specifications repo).
Common Commands
Building
npm run build:ts # Compile TypeScript to lib/
npm run check:ts # Type-check without emittingLinting
npm run check:eslint # Run ESLint
npm run fix:eslint # Auto-fix ESLint issuesTesting
Integration tests require a running MongoDB instance (unit tests do not). To start one locally:
git submodule update --init
export DRIVERS_TOOLS=$(pwd)/drivers-evergreen-tools
VERSION='latest' TOPOLOGY='replica_set' bash .evergreen/run-orchestration.sh
source mo-expansion.shnpm run check:unit # Unit tests (no database required)
npm run check:test # Integration tests (requires database)
npm test # Full check (lint + d.ts/tsd) + unit + integration
# Run a single test by name pattern
npm run check:unit -- -g "pattern"
npm run check:test -- -g "pattern"Tests use Mocha with 60-second timeout. Integration tests use a custom metadata UI that supports test filtering by topology, MongoDB version, auth, etc. via metadata:
describe(
'my test',
{ metadata: { requires: { topology: ['replicaset'], mongodb: '>=6.0' } } },
function () {}
);Architecture
Layered Design
Public API (MongoClient, Db, Collection, Cursors)
→ Operations (CRUD, Aggregation, Indexes, Bulk writes)
→ Sessions & Transactions
→ SDAM – Server Discovery And Monitoring (src/sdam/)
→ CMAP – Connection Management And Pooling (src/cmap/)
→ Wire Protocol & BSON serializationKey Source Directories
src/operations/— Each database command is anAbstractOperationsubclass. Operations declare aspects (retryable, read/write, explainable) via Symbols.execute_operation.tsis the central execution engine handling retries, sessions, server selection.src/sdam/— Topology discovery and monitoring.topology.tsmanages servers,server_selection.tspicks the best server based on read preference and latency,monitor.tssends periodic heartbeats.src/cmap/— Connection pooling per server, wire protocol encoding/decoding, authentication handshakes.auth/contains implementations for each auth mechanism (SCRAM, X.509, AWS, OIDC, Kerberos, PLAIN).src/cursor/—AbstractCursorbase with lazy evaluation, async iteration, and streaming. Specialized cursors:FindCursor,AggregationCursor,ChangeStreamCursor, etc.src/bulk/— Ordered and unordered bulk write operations.src/client-side-encryption/— Auto-encryption and explicit encryption (CSFLE/Queryable Encryption).src/gridfs/— GridFS file storage using upload/download streams.
How Operations Execute
- User calls a method (e.g.,
collection.insertOne()) - An operation object is created (e.g.,
InsertOperation) executeOperation()handles: implicit session creation → server selection → connection checkout → command building → wire protocol send → response handling → retry on transient errors- Connection returned to pool, session cleaned up
Test Structure
test/unit/— Mirrorssrc/structure. No database interaction, uses mocks.test/integration/— Real database tests organized by feature area.test/spec/— YAML/JSON test specifications from the cross-driver specs. Implemented by spec runners in integration tests. Files named*.spec.test.tsuse standardized runners;*.prose.test.tsare hand-written prose test implementations.test/mongodb.ts— Central re-export of allsrc/internals for test access. Tests import from../../mongodb(or appropriate depth), never directly fromsrc/.
Code Conventions
- Public API stability — Anything exported from
src/index.tsflows into the publishedmongodb.d.tsvia api-extractor. Renaming, removing, or narrowing exported types/signatures is a breaking change; confirm with a maintainer before doing so. - No
export default— All exports must be named. - No TypeScript enums — Use string unions or
as constobjects instead. src/: nonode:import prefix — In source files, use bare module names (e.g.,import { setTimeout } from 'timers'). Tests may usenode:imports where allowed by the repo config.src/: timer/process imports — In source files, importsetTimeout,setInterval,clearTimeout,process, etc. from their modules instead of using globals.- No
Buffer— UseUint8Arrayin source code. - BSON imports — Source code must import from
src/bson.ts, not from thebsonpackage directly. - Null/undefined checks — Use loose equality (
== null) not strict (=== nullor=== undefined). - Type imports — Use
import { type Foo }(inline type imports). return await— Required insrc/(enforced by@typescript-eslint/return-await: always).- Error messages — Sentence case, no trailing period. Use driver-specific error types extending
MongoError. - Formatting — Prettier with single quotes, 2-space indentation, 100-char width, no trailing commas.
Commit Messages
Follow Conventional Commits: <type>(NODE-XXXX): <subject>
Types: feat, fix, docs, style, refactor, perf, test, chore
Breaking changes use !: feat(NODE-XXXX)!: description
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

