Skip to content

[Workers] Add MongoDB integration docs#31382

Draft
MattieTK wants to merge 9 commits into
productionfrom
feat/mongodb-docs
Draft

[Workers] Add MongoDB integration docs#31382
MattieTK wants to merge 9 commits into
productionfrom
feat/mongodb-docs

Conversation

@MattieTK

@MattieTK MattieTK commented Jun 10, 2026

Copy link
Copy Markdown
Member

Summary

Adds documentation for connecting Cloudflare Workers to MongoDB using the native Node.js driver (mongodb >= 6.15.0) and Mongoose. We occasionally get requests in discord for information on how to do this since we don't support these drivers in Hyperdrive, and setting up database connections on a request-basis is inefficient.

Three changes:

  1. New integration page at /workers/databases/third-party-integrations/mongodb/ – covers both a direct connection (simple, ~300ms overhead per request) and a Durable Object approach (recommended, persists connections for ~35ms warm queries). Also documents the Mongoose package.json exports patch required for workerd compatibility.

  2. Table row added to /workers/databases/connecting-to-databases/ under the serverless databases section, listing MongoDB with the mongodb/mongoose drivers and TCP Socket as the connection method.

  3. New tutorial at /workers/tutorials/connect-to-mongodb-atlas/ – a step-by-step guide that creates a Worker, connects to MongoDB, queries a sample collection, then upgrades to a Durable Object for lower latency.

Relevant upstream context:

Documentation checklist

  • Is there a changelog entry (guidelines)? If you don't add one for something awesome and new (however small) — how will our customers find out? Changelogs are automatically posted to RSS feeds, the Discord, and X.
  • The change adheres to the documentation style guide.
  • If a larger change - such as adding a new page- an issue has been opened in relation to any incorrect or out of date information that this PR fixes.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:

Pattern Owners
/src/content/docs/workers/ @cloudflare/workers-docs, @GregBrimble, @irvinebroque, @mikenomitch, @korinne, @WalshyDev, @cloudflare/deploy-config, @cloudflare/product-owners, @cloudflare/wrangler, @MattieTK, @cloudflare/dev-plat-leads, @vy-ton

@ask-bonk ask-bonk Bot added content:new Request for new/missing content documentation Documentation edits labels Jun 10, 2026

@ask-bonk ask-bonk Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues need fixing before merge.

HIGH — Workers TypeScript examples must use TypeScriptExample (not bare ts/typescript fences). I suggested the most prominent blocks; please apply the same wrapper to any remaining examples on both pages.

HIGHWranglerConfig blocks must use TOML input and $today for compatibility_date instead of JSONC/hardcoded dates.

MEDIUM — The tutorial output block should use txt output rather than sh output.

Comment thread src/content/docs/workers/databases/third-party-integrations/mongodb.mdx Outdated
Comment thread src/content/docs/workers/tutorials/connect-to-mongodb-atlas.mdx Outdated
Comment thread src/content/docs/workers/tutorials/connect-to-mongodb-atlas.mdx Outdated
Comment thread src/content/docs/workers/tutorials/connect-to-mongodb-atlas.mdx
Comment thread src/content/docs/workers/tutorials/connect-to-mongodb-atlas.mdx
Comment thread src/content/docs/workers/tutorials/connect-to-mongodb-atlas.mdx
@ask-bonk

ask-bonk Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review posted on PR #31382.

Labels applied: product:workers, content:new, documentation.

Summary of findings:

Severity Issue Location
HIGH Workers TypeScript examples use bare ts/typescript fences instead of the required TypeScriptExample component. mongodb.mdx (3 blocks), tutorial (3 blocks)
HIGH WranglerConfig blocks use JSONC input and hardcoded compatibility_date instead of TOML + $today. mongodb.mdx, tutorial
MEDIUM Command output block uses sh output instead of txt output. Tutorial step 4

I posted 11 inline suggestions covering the import additions, representative TypeScriptExample wrappers, both WranglerConfig conversions, and the output language fix. The author should apply the same TypeScriptExample wrapper to any smaller typescript snippets I didn't individually flag (e.g., the step 5 import snippets in the tutorial).

No pre-existing issues in unchanged files were flagged. The content is technically accurate and the structure is solid once the component/style-guide violations are resolved.

github run

MattieTK and others added 8 commits June 11, 2026 13:38
…ngodb.mdx

Co-authored-by: ask-bonk[bot] <249159057+ask-bonk[bot]@users.noreply.github.com>
…ngodb.mdx

Co-authored-by: ask-bonk[bot] <249159057+ask-bonk[bot]@users.noreply.github.com>
…ngodb.mdx

Co-authored-by: ask-bonk[bot] <249159057+ask-bonk[bot]@users.noreply.github.com>
Co-authored-by: ask-bonk[bot] <249159057+ask-bonk[bot]@users.noreply.github.com>
…ngodb.mdx

Co-authored-by: ask-bonk[bot] <249159057+ask-bonk[bot]@users.noreply.github.com>
Co-authored-by: ask-bonk[bot] <249159057+ask-bonk[bot]@users.noreply.github.com>
Close TypeScriptExample and WranglerConfig blocks that were missing
fence/tag terminators, and fill in the empty example blocks in the
MongoDB integration page and Atlas tutorial.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

content:new Request for new/missing content documentation Documentation edits product:workers Related to Workers product size/l

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants