koa-mongo is a MongoDB middleware for Koa 2 that provides connection pool management via generic-pool. Version 1.9.3 is the latest stable release. It attaches an initialized MongoClient to `ctx.mongo` and a database handle to `ctx.db`, allowing direct access to native MongoDB driver methods. Supports both URI and separate host/port configuration. Compared to alternatives like koa-mongodb, koa-mongo is lightweight and explicitly integrates with Koa's middleware pattern, but relies on the deprecated MongoDB driver v3.x API and lacks built-in TypeScript types.
npm install koa-mongoNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic setup with URI configuration and a simple insert operation using ctx.db.
Replace insert() with insertOne() and remove() with deleteOne() or deleteMany(), and ensure _id is a string if needed.
Use the uri option for connection and pass native driver options as a second argument.
Use ctx.mongo.db('otherDb') to access a different database.Install @types/koa-mongo or write custom type declarations.
Use koa@2.x or higher.
Ensure mongo() middleware is added before any route handlers and that the MongoDB server is running.
Run: npm install mongodb
Replace insert() with insertOne() or insertMany().
Provide user, pass, and authSource in options or use a URI with authentication.