Examples Gallery

Every core API in the documentation site should map, as much as possible, to an example that can run directly inside the current repository.

See the official examples index for the full source list. npm run test:examples compiles and executes the current 57 TypeScript examples. examples/helpers/bootstrap.ts is a helper module and is not executed on its own.

How to Run

npm run build
npm run test:examples

npm run test:examples starts a shared mongodb-memory-server standalone instance and replica set in the parent process. It performs health checks between examples and passes the URI to every example child process. Binary cache is fixed at .cache/mongodb-memory-server/binaries, while temporary data directories are fixed at .cache/mongodb-memory-server/db and cleaned up on exit.

You can also run any example individually:

tsc -p tsconfig.examples.json
node .generated/examples-dist/examples/docs/find.js

Intro Examples

Query Operations

Write Operations

Advanced Capabilities

Some conceptual pages intentionally reuse the same richer example instead of duplicating nearly identical scripts for every heading. The complete source of truth is the official examples index.