本文へスキップ
記事初級

Cloudflare Workers から MongoDB に接続する

ネイティブの Node.js ドライバーで Cloudflare Worker を MongoDB に接続し、Durable Object で接続を保持して遅延を減らします。

最終更新
2026年10月16日
元の記事を読む

この紹介文は現在英語版のみです。

Query a movies database in MongoDB from a Worker. You start with a direct connection, then move it into a Durable Object so connections persist between requests. Hyperdrive doesn’t support MongoDB (only the PostgreSQL and MySQL wire protocols), which is why the tutorial uses this pattern.

What you’ll learn

  • Enable Node.js compatibility and add the MongoDB driver
  • Connect and query from a Worker
  • Deploy, then reuse connections with a Durable Object

Cloudflare products used

Workers, Durable Objects.

Follow the full, step-by-step tutorial in Cloudflare’s documentation.

さらに学ぶ