{"_id":"@codefresh-io/mongoose-paginate","_rev":"25-e92e8aea2fdfd8176a6976a52edda9d5","name":"@codefresh-io/mongoose-paginate","dist-tags":{"latest":"6.0.2"},"versions":{"6.0.1":{"name":"@codefresh-io/mongoose-paginate","version":"6.0.1","keywords":["mongoose","paginate","pagination","paging","page"],"author":{"name":"Edward Hotchkiss","email":"edward@edwardhotchkiss.com"},"license":"MIT","_id":"@codefresh-io/mongoose-paginate@6.0.1","maintainers":[{"name":"scme0","email":"scottyjoe9@gmail.com"},{"name":"bogdan-volynets","email":"bogdan.volynets@codefresh.io"},{"name":"vasil-s","email":"vasil.sudakov@codefresh.io"},{"name":"vitalii.chyrka","email":"vitalii.chyrka@codefresh.io"},{"name":"kimaharfi","email":"kim.aharfi@codefresh.io"},{"name":"ilia-medvedev-codefresh","email":"ilia.medvedev@codefresh.io"},{"name":"z-tikhonov-codefresh","email":"zhenya.tikhonov@codefresh.io"},{"name":"eticodefresh","email":"eti.zaguri@codefresh.io"},{"name":"denis-codefresh","email":"denis@codefresh.io"},{"name":"plakyda-codefresh","email":"victor@codefresh.io"},{"name":"codefresh","email":"admin@codefresh.io"},{"name":"andrii-codefresh","email":"andrii@codefresh.io"},{"name":"oleksandr-codefresh","email":"oleksandr.saulyak@codefresh.io"},{"name":"noam-codefresh","email":"noam.gal@octopus.com"},{"name":"bohdan.pisarenko","email":"bohdan.pisarenko@codefresh.io"},{"name":"mikeshl","email":"michael.shlomo@codefresh.io"},{"name":"yaroslav-codefresh","email":"yaroslav@codefresh.io"},{"name":"atgardner","email":"atgardner+npm@gmail.com"}],"contributors":[{"name":"Edward Hotchkiss","email":"edward@edwardhotchkiss.com"},{"name":"Nick Baugh","email":"niftylettuce@gmail.com"},{"name":"Dmitry Kirilyuk","email":"gk.joker@gmail.com"}],"homepage":"https://github.com/codefresh-io/mongoose-paginate#readme","bugs":{"url":"https://github.com/codefresh-io/mongoose-paginate/issues"},"dist":{"shasum":"461f3451bc63b893e19d291af5ff28554f391de4","tarball":"https://registry.npmjs.org/@codefresh-io/mongoose-paginate/-/mongoose-paginate-6.0.1.tgz","fileCount":12,"integrity":"sha512-mTwakefWjqQt8kK4ViaYaSAHq8WYZ+tt1AiIrIheVBc7Ig3W86Z5/aXF8Fu6rZhdcmKl20vMILKVc8TCv47Pkw==","signatures":[{"sig":"MEUCIGMilbxfy/4JOwKw+xTCo3E17UHEmixCVRKCH82W9DUmAiEA98n+nrF14ow8Mlpmqno5aVtUWAS56nCKVfT2t5lpeYg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":2909276},"engines":{"node":">=20.0.0"},"gitHead":"f4ca6a558b0a2f2424d253cd184e5c3352b82371","scripts":{"test":"npx jest .","eslint":"exit 0"},"_npmUser":{"name":"codefresh","email":"admin@codefresh.io"},"repository":{"url":"git+https://github.com/codefresh-io/mongoose-paginate.git","type":"git"},"_npmVersion":"5.4.2","description":"Pagination plugin for Mongoose","directories":{},"_nodeVersion":"8.8.0","_hasShrinkwrap":false,"packageManager":"yarn@4.4.1","devDependencies":{"jest":"^29.7.0","mongoose":"^8.6.0","@types/jest":"^29.5.12","mongodb-memory-server":"^10.0.0"},"_npmOperationalInternal":{"tmp":"tmp/mongoose-paginate_6.0.1_1725449530656_0.5258074516318345","host":"s3://npm-registry-packages"}},"6.0.2":{"name":"@codefresh-io/mongoose-paginate","version":"6.0.2","keywords":["mongoose","paginate","pagination","paging","page"],"author":{"name":"Edward Hotchkiss","email":"edward@edwardhotchkiss.com"},"license":"MIT","_id":"@codefresh-io/mongoose-paginate@6.0.2","maintainers":[{"name":"gil-levkovitch","email":"gil.levkovitch@codefresh.io"},{"name":"scme0","email":"scottyjoe9@gmail.com"},{"name":"bogdan-volynets","email":"bogdan.volynets@codefresh.io"},{"name":"vasil-s","email":"vasil.sudakov@codefresh.io"},{"name":"vitalii.chyrka","email":"vitalii.chyrka@codefresh.io"},{"name":"kimaharfi","email":"kim.aharfi@codefresh.io"},{"name":"ilia-medvedev-codefresh","email":"ilia.medvedev@codefresh.io"},{"name":"z-tikhonov-codefresh","email":"zhenya.tikhonov@codefresh.io"},{"name":"eticodefresh","email":"eti.zaguri@codefresh.io"},{"name":"denis-codefresh","email":"denis@codefresh.io"},{"name":"plakyda-codefresh","email":"victor@codefresh.io"},{"name":"codefresh","email":"admin@codefresh.io"},{"name":"andrii-codefresh","email":"andrii@codefresh.io"},{"name":"oleksandr-codefresh","email":"oleksandr.saulyak@codefresh.io"},{"name":"noam-codefresh","email":"noam.gal@octopus.com"},{"name":"bohdan.pisarenko","email":"bohdan.pisarenko@codefresh.io"},{"name":"mikeshl","email":"michael.shlomo@codefresh.io"},{"name":"yaroslav-codefresh","email":"yaroslav@codefresh.io"},{"name":"atgardner","email":"atgardner+npm@gmail.com"}],"contributors":[{"name":"Edward Hotchkiss","email":"edward@edwardhotchkiss.com"},{"name":"Nick Baugh","email":"niftylettuce@gmail.com"},{"name":"Dmitry Kirilyuk","email":"gk.joker@gmail.com"}],"homepage":"https://github.com/codefresh-io/mongoose-paginate#readme","bugs":{"url":"https://github.com/codefresh-io/mongoose-paginate/issues"},"dist":{"shasum":"47c0d2003925625a8ef273eaa71bf6e4398c08c4","tarball":"https://registry.npmjs.org/@codefresh-io/mongoose-paginate/-/mongoose-paginate-6.0.2.tgz","fileCount":5,"integrity":"sha512-rGEOmwwLG4+8TKW1Vmgx+mdBzX+NW+dnzEwFAYXsabtsQNmV5YL0mSoVwpDxUAo9fgDSLlt9kxYg56dGysx06A==","signatures":[{"sig":"MEYCIQCwVMC7U4PtjdE/6h0pIE2jcyuYOdxWGLTkakdgk7crxwIhALFsk9+OHSC5ME1unKBi0GEJ6vZ1nIeuCx7W50vdE/NO","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14438},"main":"index.js","engines":{"node":">=20.0.0"},"gitHead":"76b7532fe85c83c933e7c3d33f3a081acfc4ab5c","scripts":{"test":"npx jest .","eslint":"exit 0"},"_npmUser":{"name":"codefresh","email":"admin@codefresh.io"},"repository":{"url":"git+https://github.com/codefresh-io/mongoose-paginate.git","type":"git"},"_npmVersion":"5.4.2","description":"Pagination plugin for Mongoose","directories":{},"_nodeVersion":"8.8.0","_hasShrinkwrap":false,"packageManager":"yarn@4.4.1","devDependencies":{"jest":"^29.7.0","mongoose":"^8.6.0","@types/jest":"^29.5.12","mongodb-memory-server":"^10.0.0"},"_npmOperationalInternal":{"tmp":"tmp/mongoose-paginate_6.0.2_1725450138631_0.6343869790349563","host":"s3://npm-registry-packages"}}},"time":{"created":"2024-09-04T11:32:10.655Z","modified":"2026-09-01T17:42:47.147Z","6.0.0":"2024-09-04T10:32:37.763Z","6.0.1":"2024-09-04T11:32:10.922Z","6.0.2":"2024-09-04T11:42:18.766Z"},"bugs":{"url":"https://github.com/codefresh-io/mongoose-paginate/issues"},"author":{"name":"Edward Hotchkiss","email":"edward@edwardhotchkiss.com"},"license":"MIT","homepage":"https://github.com/codefresh-io/mongoose-paginate#readme","keywords":["mongoose","paginate","pagination","paging","page"],"repository":{"url":"git+https://github.com/codefresh-io/mongoose-paginate.git","type":"git"},"description":"Pagination plugin for Mongoose","contributors":[{"name":"Edward Hotchkiss","email":"edward@edwardhotchkiss.com"},{"name":"Nick Baugh","email":"niftylettuce@gmail.com"},{"name":"Dmitry Kirilyuk","email":"gk.joker@gmail.com"}],"maintainers":[{"email":"zhenya.tikhonov@codefresh.io","name":"z-tikhonov-codefresh"},{"email":"denis@codefresh.io","name":"denis-codefresh"},{"email":"yaroslav@codefresh.io","name":"yaroslav-codefresh"},{"email":"chris.campos@codefresh.io","name":"chris.campos"},{"email":"bohdan.pisarenko@codefresh.io","name":"bohdan.pisarenko"},{"email":"andrii@codefresh.io","name":"andrii-codefresh"},{"email":"gil.levkovitch@codefresh.io","name":"gil-levkovitch"},{"email":"kim.aharfi@codefresh.io","name":"kimaharfi"},{"email":"phil.warne-smith@codefresh.io","name":"philcodefresh"},{"email":"eti.zaguri@codefresh.io","name":"eticodefresh"},{"email":"admin@codefresh.io","name":"codefresh"},{"email":"angus.field@codefresh.io","name":"angusfield"},{"email":"vadim.kharin@codefresh.io","name":"vadim-kharin-codefresh"},{"email":"vitalii.chyrka@codefresh.io","name":"vitalii.chyrka"},{"email":"ziv.levi@octopus.com","name":"ziv_levi"},{"email":"alina.shklyar@codefresh.io","name":"alinashklyarcodefresh"},{"email":"mikhail.klimko@codefresh.io","name":"mikhail-klimko-codefresh"},{"email":"alina.shportiuk@codefresh.io","name":"alina_yablochnikova"}],"readme":"\n# @codefresh-io/mongoose-paginate\n\n> Fork of [`mongoose-paginate`](https://github.com/edwardhotchkiss/mongoose-paginate), maintained by [Codefresh](https://codefresh.io/).\n\nPagination plugin for [Mongoose](http://mongoosejs.com).\n\n\n## Installation\n\n```sh\nnpm install @codefresh-io/mongoose-paginate\n```\n\n## Usage\n\nAdd plugin to a schema and then use model `paginate` method:\n\n```js\nconst { Model, Schema } = require('mongoose');\nconst mongoosePaginate = require('mongoose-paginate');\n\nconst schema = new mongoose.Schema({ /* schema definition */ });\nschema.plugin(mongoosePaginate);\n\nconst Model = mongoose.model('Model',  schema);\nModel.paginate();\n```\n\n### Model.paginate([filter], [options])\n\n**Parameters**\n\n* `[filter]` {Object} - Query filter. [*(Documentation)*](https://mongoosejs.com/docs/api/model.html#Model.find())\n* `[options]` {Object}\n  - `[select]` {Object | String} - Fields to return (by default returns all fields). [*(Documentation)*](http://mongoosejs.com/docs/api.html#query_Query-select)\n  - `[sort]` {Object | String} - Sort order. [*(Documentation)*](http://mongoosejs.com/docs/api.html#query_Query-sort)\n  - `[populate]` {Array | Object | String} - Paths which should be populated with other documents. [*(Documentation)*](http://mongoosejs.com/docs/api.html#query_Query-populate)\n  - `[lean=false]` {Boolean} - Should return plain javascript objects instead of Mongoose documents? [*(Documentation)*](http://mongoosejs.com/docs/api.html#query_Query-lean)\n  - `[leanWithId=true]` {Boolean} - If `lean` and `leanWithId` are `true`, adds `id` field with string representation of `_id` to every document.\n  - `[offset=0]` {Number} - Use either `offset` or `page` to set skip position\n  - `[page=1]` {Number} - Use either `offset` or `page` to set skip position\n  - `[limit=10]` {Number} - If `limit===0`, empty array will be returned.\n\n**Return value**\n\nPromise fulfilled with object having properties:\n* `docs` {Array} - Array of documents. Empty array, if `limit===0`.\n* `total` {Number} - Total number of documents in collection that match a query. If query filter was omit or empty, estimated number of docs will be returned.\n* `limit` {Number} - Limit that was used\n* `[page]` {Number} - Only if specified or default `page`/`offset` values were used \n* `[pages]` {Number} - Only if `page` specified or default `page`/`offset` values were used \n* `[offset]` {Number} - Only if specified or default `page`/`offset` values were used\n\n### Examples\n\n#### Skip 20 documents and return 10 documents\n\n```js\nconst result = await Model.paginate({}, { page: 3, limit: 10 });\n/*\n{\n  docs: <Array>,\n  total: <Number>,\n  limit: 10,\n  page: 3,\n  pages: <Number>,\n}\n*/\n```\n\nOr you can do the same with `offset` and `limit`:\n\n```js\nconst result = await Model.paginate({}, { offset: 20, limit: 10 });\n/*\n{\n  docs: <Array>,\n  total: <Number>,\n  limit: 10,\n  offset: 20,\n}\n*/\n```\n\n#### More advanced example\n\n```js\nconst filter = {};\nconst options = {\n  select: 'title date author',\n  sort: { date: -1 },\n  populate: 'author',\n  lean: true,\n  offset: 20, \n  limit: 10\n};\n\nconst result = Book.paginate(filter, options);\n```\n\n#### Zero limit\n\nYou can use `limit=0` to get only metadata:\n\n```js\nconst result = await Model.paginate({}, { offset: 100, limit: 0 });\n/*\n{\n  docs: [],         // empty array\n  total: <Number>,\n  limit: 0,\n  offset: 100,\n}\n*/\n```\n\n#### Set custom default options for all queries\n\n```js\nconst { paginate } = require('mongoose-paginate');\n\npaginate.options = { \n  lean:  true,\n  limit: 20\n};\n\n// ...\n\nconst result = await Model.paginate();\n/*\n{\n  docs: <Array>,  // array of POJO\n  limit: 20,      // default limit 20 was applied\n}\n*/\n```\n\n## Tests\n\n```sh\nyarn install\nyarn test\n```\n\n## License\n\n[MIT](LICENSE)\n","readmeFilename":"README.md"}