@web3bot/egg-mongodb
v1.0.2
Published
<!-- egg use mongodb -->
Readme
egg-mongodb
Install
$ npm i @web3bot/egg-mongodb --saveUsage
// {app_root}/config/plugin.js
exports.mongodb = {
enable: true,
package: "@web3bot/egg-mongodb",
};Configuration
// {app_root}/config/config.default.js
exports.mongodb = {
client: {
url: "mongodb://<user>:<password>@<ip>:<port>/?authSource=<DBName>",
dbName: "",
options: {},
},
};
// Replica Set
exports.mongodb = {
client: {
url: "mongodb://<user>:<password>@<ip>:<port>,<ip2>:<port2>,<ip3>:<port3>/?authSource=<DBName>",
dbName: "",
options: {},
},
};see config/config.default.js for more detail.
Example
async test() {
const collection = this.app.mongodb.collection('test');
const result = await collection.find({ });
console.log(result);
}Questions & Suggestions
Please open an issue here.
