{"_id":"@awamwang/egg-mongoose","_rev":"1-0e1199fc0c2154f66b80e0696254ba9e","name":"@awamwang/egg-mongoose","dist-tags":{"latest":"7.0.1"},"versions":{"6.0.1":{"name":"@awamwang/egg-mongoose","version":"6.0.1","description":"egg mongoose plugin","eggPlugin":{"name":"mongoose"},"keywords":["egg","egg-model","mongoose","eggPlugin","egg-plugin"],"dependencies":{"await-first":"^1.0.0","mongoose":"^6.4.1"},"devDependencies":{"@types/node":"^16.0.0","autod":"^3.1.2","bluebird":"^3.7.2","dotenv":"^16.0.1","egg":"^2.36.0","egg-bin":"^5.1.1","egg-mock":"^4.2.1","eslint":"^8.18.0","eslint-config-egg":"^12.0.0","mocha":"^10.0.0","supertest":"^6.2.3","typescript":"^4.7.4","webstorm-disable-index":"^1.2.0"},"engines":{"node":">=6.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","autod":"autod"},"ci":{"version":"10, 16, 18"},"repository":{"type":"git","url":"git+https://github.com/awamwang/egg-mongoose.git"},"bugs":{"url":"https://github.com/eggjs/egg/issues"},"publishConfig":{"access":"public"},"types":"./index.d.ts","gitHead":"44dfce91efda833b09e915905007929239476cb9","homepage":"https://github.com/awamwang/egg-mongoose#readme","_id":"@awamwang/egg-mongoose@6.0.1","_nodeVersion":"16.15.1","_npmVersion":"8.11.0","dist":{"integrity":"sha512-fBUJ47xz54oht9pADVX5lpYegIwSRNBJrdHwA+KGvp5oltgVqUkhiwN0EbPKvEpgHsLPCz0d2WkZwgcsybsSGA==","shasum":"9dad9b872860769086115d378ff4ef1a3be7ad03","tarball":"https://registry.npmjs.org/@awamwang/egg-mongoose/-/egg-mongoose-6.0.1.tgz","fileCount":10,"unpackedSize":12575,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGfUFwHNxEUPLWvtKu+4fs9Pk+gviaxJl31q5JR9yKDaAiEA/g6aSSgiYXr3kU3mMmJZEqkmk62hkI5BXAqyXwKvGak="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJivVFDACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpSRg/+NEBKu9oZsR/NmFp0NPgdfeC8GRj/RHh2CAHhJLHWl3uSOGZk\r\n8GmBFqEk/8StFbbKHp6LTWKESaYuPhBqvmfRtzxBZaffH595ILoZR0M2e261\r\norK46Vm7E9dMV97uHWb7nn+Jgq2P5lULwKaX3OJdufS8KzzjhqLgCH6bk90I\r\n3beW3e6kHzDEWkpJdOkNatMgtcxQKMjQc5OAnFvIt9DzIKsexYwXR7t+5o2F\r\n1MY8Nk+8hw5USCTrPMQkhwQ6xavVxozNFOnOaovjn9rMwidvZfLILVuY8NW9\r\nYyFtLy2xvM4R21VsKg2nrtRHI+njNGCHfOeCzIj/lu2ENYy+iKA8dSEhNbFX\r\nubr36MJazAHvduPqNpogViqkdOII+M7jpI9iV4yMQK5XV1efQTFsEo8lecQl\r\nZS34U/BJNEXmuwJKhpVSd+H0f72v9YIwYa30KSDlmlru7DrArOzx8henzquR\r\nDW4ye//pv9rcrLkOaOax42ab607E8j1yFXluu/xfwT7kKYUYzqMaOWUYNeGR\r\nMOUnpjjrZ/xAL/72geqBqtrAKymoS8deuqg6OUoS+ovuPgO5b3CKwvZ2hLNl\r\nV5VM/gUZpC4RrRAe+O9xJfeFxuhAqbtFntk9tI1rSzBshy8foAdOeq6/GCe5\r\nUl51hOYOQV5oxPtAZsdxTSEWdkLEsrj6uew=\r\n=kGO6\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"awamwang","email":"wm.keepgoing@gmail.com"},"directories":{},"maintainers":[{"name":"awamwang","email":"wm.keepgoing@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/egg-mongoose_6.0.1_1656574275568_0.513349668249172"},"_hasShrinkwrap":false},"7.0.1":{"name":"@awamwang/egg-mongoose","version":"7.0.1","description":"egg mongoose plugin","eggPlugin":{"name":"mongoose"},"keywords":["egg","egg-model","mongoose","eggPlugin","egg-plugin"],"dependencies":{"await-first":"^1.0.0"},"devDependencies":{"@types/node":"^16.0.0","autod":"^3.1.2","bluebird":"^3.7.2","dotenv":"^16.0.1","egg":"^2.36.0","egg-bin":"^5.1.1","egg-mock":"^4.2.1","eslint":"^8.18.0","eslint-config-egg":"^12.0.0","mocha":"^10.0.0","mongoose":"^7.0.3","supertest":"^6.2.3","typescript":"^4.7.4","webstorm-disable-index":"^1.2.0"},"engines":{"node":">=6.0.0"},"ci":{"version":"10, 16, 18"},"repository":{"type":"git","url":"git+https://github.com/awamwang/egg-mongoose.git"},"bugs":{"url":"https://github.com/eggjs/egg/issues"},"publishConfig":{"access":"public"},"peerDependencies":{"mongoose":"^7.0.3"},"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","autod":"autod"},"types":"./index.d.ts","homepage":"https://github.com/awamwang/egg-mongoose#readme","_id":"@awamwang/egg-mongoose@7.0.1","_integrity":"sha512-mVR+SCrHAeHpYUrjp0Oq4tre9MbF8JuD3qu1YqMMXHEorGszj5i+arLQ8Fta4Dp7MprbDXYNHdvxkAME4UExSw==","_resolved":"C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\66366223a1688cc27f84ce2d9c6f348c\\awamwang-egg-mongoose-7.0.1.tgz","_from":"file:awamwang-egg-mongoose-7.0.1.tgz","_nodeVersion":"16.15.1","_npmVersion":"8.11.0","dist":{"integrity":"sha512-mVR+SCrHAeHpYUrjp0Oq4tre9MbF8JuD3qu1YqMMXHEorGszj5i+arLQ8Fta4Dp7MprbDXYNHdvxkAME4UExSw==","shasum":"3a974213ee499e0c8a077a0f1ef3f2426015448b","tarball":"https://registry.npmjs.org/@awamwang/egg-mongoose/-/egg-mongoose-7.0.1.tgz","fileCount":10,"unpackedSize":12906,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID+lADAZn3xJHeJDKXoZ/Lbyfnpxywj1ewXrBzD7nilPAiEA6M6AXMnteb33YluFAj+IkXiIuFwGe62x1WBuL//g/oY="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkKtllACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqyQRAAkFaLAvAfz7mOzVda31ikmu6vrMYp6GDDWgdY471+d12IekVL\r\nwxEmf/GHd6ZU4UMA0Spcm5KtAckA1ofhQ37PEaOqSvLqjRU6PcMgUZEXmZVr\r\nIXe2wJGeQcA0UUeoTmv4sEyeG7SvOURD6fsHXZdzRxtec87gdGEa2E8g/lL1\r\nYjG52nVzvmGyINNvITJ/Y1R1xxWHvE6myofhkfowO9GYtYW/6josEQeWBvsI\r\n4FFfycjGvqWyp10/MK0OHwUfSKVp9qy285QOmcqeMQpN4gKZXy9QhO+2l1qY\r\nOMB561Wmo5jLaNxF1DznTY3M4Hm8ccNB0fOI3X3+NueL7PZROXVJ8hEZyuqj\r\nYp1YdIohtai4ElGwAwpHSRskDtWgHOHCdytTZHON2x0xSxv40luO+FY4kt20\r\ng1R9qwzYm/NX+9OGzVB6MzKGtivmNDXkHA4Rq4dNSDrQob7EZ9mMy0INR6/K\r\ntjM9o85JnRUYB03iX9SGQXXv74o7LolgqZMP18xW65f+d8fwbe6QYhP+HlpW\r\nw1RJlUp67UW86wh6bgEwbBtJw75eHmTSULMjre/YrQTdXqjSxTC84a91NyzZ\r\nn6Gzu5fWsknqQaEOwS/iKcxONIcCKmD/OOmyln2Wu9hQ346zQvqM8yIXN2/p\r\naptjkBZYdtCiIRlJGZUNSvRAUGLNk6NNXhQ=\r\n=WWgi\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"awamwang","email":"wm.keepgoing@gmail.com"},"directories":{},"maintainers":[{"name":"awamwang","email":"wm.keepgoing@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/egg-mongoose_7.0.1_1680529765625_0.25122659240892786"},"_hasShrinkwrap":false}},"time":{"created":"2022-06-30T07:31:15.511Z","6.0.1":"2022-06-30T07:31:15.704Z","modified":"2023-04-03T13:49:25.966Z","7.0.1":"2023-04-03T13:49:25.811Z"},"maintainers":[{"name":"awamwang","email":"wm.keepgoing@gmail.com"}],"description":"egg mongoose plugin","homepage":"https://github.com/awamwang/egg-mongoose#readme","keywords":["egg","egg-model","mongoose","eggPlugin","egg-plugin"],"repository":{"type":"git","url":"git+https://github.com/awamwang/egg-mongoose.git"},"bugs":{"url":"https://github.com/eggjs/egg/issues"},"readme":"# egg-mongoose\n\n[![NPM version][npm-image]][npm-url]\n[![build status][travis-image]][travis-url]\n[![Test coverage][codecov-image]][codecov-url]\n[![David deps][david-image]][david-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/@awamwang/egg-mongoose\n[travis-image]: https://img.shields.io/travis/eggjs/egg-mongoose.svg?style=flat-square\n[travis-url]: https://travis-ci.org/eggjs/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[david-image]: https://img.shields.io/david/eggjs/egg-mongoose.svg?style=flat-square\n[david-url]: https://david-dm.org/eggjs/egg-mongoose\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/@awamwang/egg-mongoose\n\nEgg's mongoose plugin.\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","readmeFilename":"README.md"}