{"_id":"@catalystclan/egg-mongoose","_rev":"1-e8d63d642d61ff3672208dcf9807f785","name":"@catalystclan/egg-mongoose","dist-tags":{"latest":"4.0.1-1"},"versions":{"4.0.1-0":{"name":"@catalystclan/egg-mongoose","version":"4.0.1-0","description":"egg mongoose plugin","eggPlugin":{"name":"mongoose"},"keywords":["egg","egg-model","mongoose","eggPlugin","egg-plugin"],"dependencies":{"await-first":"^1.0.0","mongoose":"^7.5.2"},"devDependencies":{"dotenv":"^7.0.0","egg":"^3.16.0","egg-bin":"^6.4.1","egg-mock":"^5.10.7","eslint":"^8.47.0","eslint-config-egg":"^12.2.1","mocha":"^10.2.0","supertest":"^4.0.2"},"engines":{"node":">=14.0.0"},"scripts":{"test":"npm run lint -- --fix && npm run test-local","test-local":"egg-bin test","cov":"egg-bin cov","lint":"eslint .","ci":"npm run lint && npm run cov","contributor":"git-contributor"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-mongoose.git"},"bugs":{"url":"https://github.com/eggjs/egg/issues"},"types":"./index.d.ts","gitHead":"c92b4633efd7451b12cd72ce105a05767a65856a","homepage":"https://github.com/eggjs/egg-mongoose#readme","_id":"@catalystclan/egg-mongoose@4.0.1-0","_nodeVersion":"18.15.0","_npmVersion":"9.5.0","dist":{"integrity":"sha512-HE7joV+0zJbR+hLC6oxg5vLnJgjSFg63wAngJQC5ye2Buf2l4O6p9plVjqRF28ZJVlwWVB0mx3cTnj6JgEQxOg==","shasum":"69f46d487063579eeff0f97d354882f041cac007","tarball":"https://registry.npmjs.org/@catalystclan/egg-mongoose/-/egg-mongoose-4.0.1-0.tgz","fileCount":10,"unpackedSize":14713,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEA3Z/cg8hN7qxUvREC5Kn/64+dphIBkRxBCrUGnn0KqAiACJJdz29Qo2acHFfmtzuHEYV1pHqpSAiqC0DSC1RvykA=="}]},"_npmUser":{"name":"jakelaoyu","email":"jake.laoyu@gmail.com"},"directories":{},"maintainers":[{"name":"jakelaoyu","email":"jake.laoyu@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/egg-mongoose_4.0.1-0_1701662835423_0.34653347940057877"},"_hasShrinkwrap":false},"4.0.1-1":{"name":"@catalystclan/egg-mongoose","version":"4.0.1-1","description":"egg mongoose plugin","eggPlugin":{"name":"mongoose"},"keywords":["egg","egg-model","mongoose","eggPlugin","egg-plugin"],"dependencies":{"await-first":"^1.0.0","mongoose":"^7.5.2"},"devDependencies":{"dotenv":"^7.0.0","egg":"^3.16.0","egg-bin":"^6.4.1","egg-mock":"^5.10.7","eslint":"^8.47.0","eslint-config-egg":"^12.2.1","mocha":"^10.2.0","supertest":"^4.0.2"},"engines":{"node":">=14.0.0"},"scripts":{"test":"npm run lint -- --fix && npm run test-local","test-local":"egg-bin test","cov":"egg-bin cov","lint":"eslint .","ci":"npm run lint && npm run cov","contributor":"git-contributor"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-mongoose.git"},"bugs":{"url":"https://github.com/eggjs/egg/issues"},"types":"./index.d.ts","gitHead":"e8f55c1c003bc5238e4e67eb8f1948953f772040","homepage":"https://github.com/eggjs/egg-mongoose#readme","_id":"@catalystclan/egg-mongoose@4.0.1-1","_nodeVersion":"18.15.0","_npmVersion":"9.5.0","dist":{"integrity":"sha512-lT73Ut4fbuwz+Q5yrXf0PCsPVqeUy17mO3ONpizKxNDKfoyAN/OnveppBg7YJAZqEMo15rF1osL8igDxCteMsw==","shasum":"a388cb28261bbb73cdbd1eb184e6e63475fbe5f0","tarball":"https://registry.npmjs.org/@catalystclan/egg-mongoose/-/egg-mongoose-4.0.1-1.tgz","fileCount":10,"unpackedSize":14723,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIF8w5xY9QOTwsICOLr9AYRLBtMDCF8cJQE95b/oZDZGIAiEA6gqPMTrjzofTHYQSNGUQkcQFcXREc4yUufJx0d6iBSs="}]},"_npmUser":{"name":"jakelaoyu","email":"jake.laoyu@gmail.com"},"directories":{},"maintainers":[{"name":"jakelaoyu","email":"jake.laoyu@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/egg-mongoose_4.0.1-1_1701663320198_0.26513034633001653"},"_hasShrinkwrap":false}},"time":{"created":"2023-12-04T04:07:15.326Z","4.0.1-0":"2023-12-04T04:07:15.624Z","modified":"2023-12-04T04:15:20.521Z","4.0.1-1":"2023-12-04T04:15:20.347Z"},"maintainers":[{"name":"jakelaoyu","email":"jake.laoyu@gmail.com"}],"description":"egg mongoose plugin","homepage":"https://github.com/eggjs/egg-mongoose#readme","keywords":["egg","egg-model","mongoose","eggPlugin","egg-plugin"],"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-mongoose.git"},"bugs":{"url":"https://github.com/eggjs/egg/issues"},"readme":"# egg-mongoose\n\n[![NPM version][npm-image]][npm-url]\n[![Run tests](https://github.com/eggjs/egg-mongoose/actions/workflows/autoUnitTest.yml/badge.svg)](https://github.com/eggjs/egg-mongoose/actions/workflows/autoUnitTest.yml)\n[![Test coverage][codecov-image]][codecov-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/egg-mongoose.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/egg-mongoose\n[codecov-image]: https://img.shields.io/codecov/c/github/eggjs/egg-mongoose.svg?style=flat-square\n[codecov-url]: https://codecov.io/github/eggjs/egg-mongoose?branch=master\n[snyk-image]: https://snyk.io/test/npm/egg-mongoose/badge.svg?style=flat-square\n[snyk-url]: https://snyk.io/test/npm/egg-mongoose\n[download-image]: https://img.shields.io/npm/dm/egg-mongoose.svg?style=flat-square\n[download-url]: https://npmjs.org/package/egg-mongoose\n\nEgg's mongoose plugin.\n\n## Install\n\n```bash\nnpm i egg-mongoose --save\n```\n\n## Configuration\n\nChange `{app_root}/config/plugin.js` to enable `egg-mongoose` plugin:\n\n```js\nexports.mongoose = {\n  enable: true,\n  package: 'egg-mongoose',\n};\n```\n\n## Simple connection\n\n### Config\n\n```js\n// {app_root}/config/config.default.js\nexports.mongoose = {\n  url: 'mongodb://127.0.0.1/example',\n  options: {},\n  // mongoose global plugins, expected a function or an array of function and options\n  plugins: [createdPlugin, [updatedPlugin, pluginOptions]],\n};\n// recommended\nexports.mongoose = {\n  client: {\n    url: 'mongodb://127.0.0.1/example',\n    options: {},\n    // mongoose global plugins, expected a function or an array of function and options\n    plugins: [createdPlugin, [updatedPlugin, pluginOptions]],\n  },\n};\n```\n\n### Example\n\n```js\n// {app_root}/app/model/user.js\nmodule.exports = app => {\n  const mongoose = app.mongoose;\n  const Schema = mongoose.Schema;\n\n  const UserSchema = new Schema({\n    userName: { type: String  },\n    password: { type: String  },\n  });\n\n  return mongoose.model('User', UserSchema);\n}\n\n// {app_root}/app/controller/user.js\nexports.index = function* (ctx) {\n  ctx.body = yield ctx.model.User.find({});\n}\n```\n\n## Multiple connections\n\n### Config\n\n```js\n// {app_root}/config/config.default.js\nexports.mongoose = {\n  clients: {\n    // clientId, access the client instance by app.mongooseDB.get('clientId')\n    db1: {\n      url: 'mongodb://127.0.0.1/example1',\n      options: {},\n      // client scope plugin array\n      plugins: []\n    },\n    db2: {\n      url: 'mongodb://127.0.0.1/example2',\n      options: {},\n    },\n  },\n  // public scope plugin array\n  plugins: []\n};\n```\n\n### Example\n\n```js\n// {app_root}/app/model/user.js\nmodule.exports = app => {\n  const mongoose = app.mongoose;\n  const Schema = mongoose.Schema;\n  const conn = app.mongooseDB.get('db1'); \n\n  const UserSchema = new Schema({\n    userName: { type: String },\n    password: { type: String },\n  });\n\n  return conn.model('User', UserSchema);\n}\n\n// {app_root}/app/model/book.js\nmodule.exports = app => {\n  const mongoose = app.mongoose;\n  const Schema = mongoose.Schema;\n  const conn = app.mongooseDB.get('db2');\n\n  const BookSchema = new Schema({\n    name: { type: String },\n  });\n\n  return conn.model('Book', BookSchema);\n}\n\n// app/controller/user.js\nexports.index = function* (ctx) {\n  ctx.body = yield ctx.model.User.find({}); // get data from db1\n}\n\n// app/controller/book.js\nexports.index = function* (ctx) {\n  ctx.body = yield ctx.model.Book.find({}); // get data from db2\n}\n```\n\n### Default config\n\nsee [config/config.default.js](config/config.default.js) for more detail.\n\n## Multi-mongos support\n\n```js\n// {app_root}/config/config.default.js\nexports.mongoose = {\n  client: {\n    url: 'mongodb://mongosA:27501,mongosB:27501',\n    options: {\n      mongos: true,\n    },\n  },\n};\n```\n\n## Questions & Suggestions\n\nPlease open an issue [here](https://github.com/eggjs/egg-mongoose/issues).\n\n## Contribution\n\nIf you are a contributor, follow [CONTRIBUTING](https://eggjs.org/zh-cn/contributing.html).\n\n## License\n\n[MIT](LICENSE)\n\n<!-- GITCONTRIBUTOR_START -->\n\n## Contributors\n\n|[<img src=\"https://avatars.githubusercontent.com/u/893152?v=4\" width=\"100px;\"/><br/><sub><b>jtyjty99999</b></sub>](https://github.com/jtyjty99999)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/360661?v=4\" width=\"100px;\"/><br/><sub><b>popomore</b></sub>](https://github.com/popomore)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/227713?v=4\" width=\"100px;\"/><br/><sub><b>atian25</b></sub>](https://github.com/atian25)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/985607?v=4\" width=\"100px;\"/><br/><sub><b>dead-horse</b></sub>](https://github.com/dead-horse)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/17738556?v=4\" width=\"100px;\"/><br/><sub><b>BaffinLee</b></sub>](https://github.com/BaffinLee)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/13268073?v=4\" width=\"100px;\"/><br/><sub><b>trylovetom</b></sub>](https://github.com/trylovetom)<br/>|\n| :---: | :---: | :---: | :---: | :---: | :---: |\n|[<img src=\"https://avatars.githubusercontent.com/u/9605663?v=4\" width=\"100px;\"/><br/><sub><b>ChangedenCZD</b></sub>](https://github.com/ChangedenCZD)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/954064?v=4\" width=\"100px;\"/><br/><sub><b>hardywu</b></sub>](https://github.com/hardywu)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/7105264?v=4\" width=\"100px;\"/><br/><sub><b>JasinYip</b></sub>](https://github.com/JasinYip)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/549979?v=4\" width=\"100px;\"/><br/><sub><b>netputer</b></sub>](https://github.com/netputer)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/52018749?v=4\" width=\"100px;\"/><br/><sub><b>Wai-Dung</b></sub>](https://github.com/Wai-Dung)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/7284558?v=4\" width=\"100px;\"/><br/><sub><b>duncup</b></sub>](https://github.com/duncup)<br/>|\n[<img src=\"https://avatars.githubusercontent.com/u/5010606?v=4\" width=\"100px;\"/><br/><sub><b>jinasonlin</b></sub>](https://github.com/jinasonlin)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/8500303?v=4\" width=\"100px;\"/><br/><sub><b>legendecas</b></sub>](https://github.com/legendecas)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/20775828?v=4\" width=\"100px;\"/><br/><sub><b>lzqmyb</b></sub>](https://github.com/lzqmyb)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/70498637?v=4\" width=\"100px;\"/><br/><sub><b>DevXiaolan</b></sub>](https://github.com/DevXiaolan)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/1774223?v=4\" width=\"100px;\"/><br/><sub><b>villins</b></sub>](https://github.com/villins)<br/>\n\nThis project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Sat Aug 12 2023 11:16:17 GMT+0800`.\n\n<!-- GITCONTRIBUTOR_END -->\n","readmeFilename":"README.md"}