1.0.2 • Published 9 months ago

@web3bot/egg-mongodb v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

egg-mongodb

Install

$ npm i @web3bot/egg-mongodb --save

Usage

// {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.

License

MIT

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago