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.