Egg.js plugin providing MongoDB integration via the official node-mongodb-native driver. Version 3.5.0 (stable). Wraps common MongoDB operations (find, insertOne, updateOne, deleteOne, aggregate) into convenient Egg.js patterns with collection name and args object, while exposing the full native driver API. Requires Egg.js application framework. Supports single instance, replica sets (v2.1.0+), and multiple instances via clients configuration. Low release cadence, focused on stability.
npm install egg-mongo-nativeNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Complete setup: install, enable plugin, configure single MongoDB instance, and use in an Egg.js controller to query a collection.
Update calls from app.mongo.find('collection', query, callback) to app.mongo.find('collection', { query, ... }).Upgrade to v2.1.0+ for replica set configuration.
Use only one: either 'client' for single instance or 'clients' for multiple databases.
Convert callbacks to async/await: const result = await app.mongo.find(...);
Check the plugin README for the full list of mapped methods.
Run 'npm i egg-mongo-native --save' and ensure it is listed in package.json. Also check config/plugin.js for correct enable and package fields.
Use app.mongo.get('dbName') to get the specific database instance first, then call methods on that instance.Check config.default.js for correct user, password, and authSource (defaults to 'admin'). Alternatively, use MONGO_URI environment variable.