{"_id":"@dakohhh/mongoose-paginator","_rev":"7-58eb3820b1a31c1df7702967ee538f8c","name":"@dakohhh/mongoose-paginator","dist-tags":{"latest":"1.0.6"},"versions":{"1.0.0":{"name":"@dakohhh/mongoose-paginator","version":"1.0.0","keywords":["mongoose","pagination","paginator","mongoose-pagination","typescript","mongo","mongodb","mongoose-paginator","paginate","class-based","lean","mongoose-query","data-pagination","nodejs","rest-api","graphql","mongoose-utility"],"author":{"name":"Wisdom Dakoh"},"license":"ISC","_id":"@dakohhh/mongoose-paginator@1.0.0","maintainers":[{"name":"dakohhh","email":"wisdomdakoh@gmail.com"}],"homepage":"https://github.com/dakohhh/mongoose-paginator#readme","bugs":{"url":"https://github.com/dakohhh/mongoose-paginator/issues"},"dist":{"shasum":"2a4c48a1b331afb041709e2a74747b0a6892aabf","tarball":"https://registry.npmjs.org/@dakohhh/mongoose-paginator/-/mongoose-paginator-1.0.0.tgz","fileCount":6,"integrity":"sha512-bqIcPFly0NWQc70IpBDg9ITeXmFsipdZFMjo3G/zeyOqORn/yLg+xER19e7ZyPwS5IOuAvLtQ5T763qQVxLxFg==","signatures":[{"sig":"MEUCIFAVUaH1NQN8+rkQB4rk8SQbkgjRHjTkMoGSqYYdWZpcAiEAmZJIW9yxJVAGIhuEvj3oOGDyCf0RnsdUYK18vwfuGcY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":13460},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"45b086bc71ceb2688ff33a6039b811ecade46940","scripts":{"build":"tsc","prepublishOnly":"npm run build"},"_npmUser":{"name":"dakohhh","email":"wisdomdakoh@gmail.com"},"repository":{"url":"git+https://github.com/dakohhh/mongoose-paginator.git","type":"git"},"_npmVersion":"10.8.2","description":"Mongoose-Class-Paginator is a lightweight, flexible, and TypeScript-friendly pagination utility for Mongoose models. It provides a class-based approach to handling database pagination with support for filtering, sorting, population, projection, and metada","directories":{},"_nodeVersion":"20.17.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.2","@types/node":"^22.13.11"},"peerDependencies":{"mongoose":"^8.13.2","@types/mongoose":"^5.11.96"},"_npmOperationalInternal":{"tmp":"tmp/mongoose-paginator_1.0.0_1743852821218_0.8248912520420126","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@dakohhh/mongoose-paginator","version":"1.0.1","keywords":["mongoose","pagination","paginator","mongoose-pagination","typescript","mongo","mongodb","mongoose-paginator","paginate","class-based","lean","mongoose-query","data-pagination","nodejs","rest-api","graphql","mongoose-utility"],"author":{"name":"Wisdom Dakoh"},"license":"ISC","_id":"@dakohhh/mongoose-paginator@1.0.1","maintainers":[{"name":"dakohhh","email":"wisdomdakoh@gmail.com"}],"homepage":"https://github.com/dakohhh/mongoose-paginator#readme","bugs":{"url":"https://github.com/dakohhh/mongoose-paginator/issues"},"dist":{"shasum":"4939e50e9decf27ca933246c211ffe8392680151","tarball":"https://registry.npmjs.org/@dakohhh/mongoose-paginator/-/mongoose-paginator-1.0.1.tgz","fileCount":6,"integrity":"sha512-uCcwb4W37AISzNxn+sowz8jnsGbgVfj6g2BNcnrYhqux8X0Sch//jMMLtGYSD6V9z0/KeHIEoppby8yVGQ7MPw==","signatures":[{"sig":"MEQCIEYsqo6CqSGUxZKdGHpeAXu42TxAh+6fNsiKGLKZBoypAiB+1n+mCUO8RyeFfz6HGHkakqqm5PrnItgdzxJGLbTrrw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":14428},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"45b086bc71ceb2688ff33a6039b811ecade46940","scripts":{"build":"tsc","prepublishOnly":"npm run build"},"_npmUser":{"name":"dakohhh","email":"wisdomdakoh@gmail.com"},"repository":{"url":"git+https://github.com/dakohhh/mongoose-paginator.git","type":"git"},"_npmVersion":"10.8.2","description":"Mongoose-Class-Paginator is a lightweight, flexible, and TypeScript-friendly pagination utility for Mongoose models. It provides a class-based approach to handling database pagination with support for filtering, sorting, population, projection, and metada","directories":{},"_nodeVersion":"20.17.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.2","@types/node":"^22.13.11"},"peerDependencies":{"mongoose":"^8.13.2","@types/mongoose":"^5.11.96"},"_npmOperationalInternal":{"tmp":"tmp/mongoose-paginator_1.0.1_1743853663793_0.5932682142177379","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@dakohhh/mongoose-paginator","version":"1.0.2","keywords":["mongoose","pagination","paginator","mongoose-pagination","typescript","mongo","mongodb","mongoose-paginator","paginate","class-based","lean","mongoose-query","data-pagination","nodejs","rest-api","graphql","mongoose-utility"],"author":{"name":"Wisdom Dakoh"},"license":"ISC","_id":"@dakohhh/mongoose-paginator@1.0.2","maintainers":[{"name":"dakohhh","email":"wisdomdakoh@gmail.com"}],"homepage":"https://github.com/dakohhh/mongoose-paginator#readme","bugs":{"url":"https://github.com/dakohhh/mongoose-paginator/issues"},"dist":{"shasum":"3b6e988e4fa8d893c3ea00a029f253d2f7bd5fa3","tarball":"https://registry.npmjs.org/@dakohhh/mongoose-paginator/-/mongoose-paginator-1.0.2.tgz","fileCount":6,"integrity":"sha512-w/A5FHPsln/cwNI5FVWD3MClQj47dOIy5OfgLwB2D4NLjOQ5sjkPlmqRsDcAgA3SJcLd0fnz6Kb1fp/drXIxlQ==","signatures":[{"sig":"MEUCIQDktW5vTgyLqlm4Su62QAX/6hObfVbczPh5J8GIgCC+NQIgKUo1LKrmCOTPN9U8bPRQNl6Vjix6wWdm8Se4RtNkPko=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":14517},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"4d5a4a3a5904405415e5a9e51adefa1109c9276c","scripts":{"build":"tsc","prepublishOnly":"npm run build"},"_npmUser":{"name":"dakohhh","email":"wisdomdakoh@gmail.com"},"repository":{"url":"git+https://github.com/dakohhh/mongoose-paginator.git","type":"git"},"_npmVersion":"10.8.2","description":"Mongoose-Class-Paginator is a lightweight, flexible, and TypeScript-friendly pagination utility for Mongoose models. It provides a class-based approach to handling database pagination with support for filtering, sorting, population, projection, and metada","directories":{},"_nodeVersion":"20.17.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.2","@types/node":"^22.13.11"},"peerDependencies":{"mongoose":"^8.13.2","@types/mongoose":"^5.11.96"},"_npmOperationalInternal":{"tmp":"tmp/mongoose-paginator_1.0.2_1744148902915_0.6723680210477794","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@dakohhh/mongoose-paginator","version":"1.0.3","keywords":["mongoose","pagination","paginator","mongoose-pagination","typescript","mongo","mongodb","mongoose-paginator","paginate","class-based","lean","mongoose-query","data-pagination","nodejs","rest-api","graphql","mongoose-utility"],"author":{"name":"Wisdom Dakoh"},"license":"ISC","_id":"@dakohhh/mongoose-paginator@1.0.3","maintainers":[{"name":"dakohhh","email":"wisdomdakoh@gmail.com"}],"homepage":"https://github.com/dakohhh/mongoose-paginator#readme","bugs":{"url":"https://github.com/dakohhh/mongoose-paginator/issues"},"dist":{"shasum":"8eb52e0c2db8c91788cf2b3f008a8e1adcb1ee9b","tarball":"https://registry.npmjs.org/@dakohhh/mongoose-paginator/-/mongoose-paginator-1.0.3.tgz","fileCount":6,"integrity":"sha512-79iwXYexOmEatgZP21qG5vFPkVc6uuzz1aY4oJcvWoTqMD2lgxL+2HQi0pG/Yf6vD3aHR5mgBzDmF8SajtgKjA==","signatures":[{"sig":"MEUCIQCPBQyNJ5Roxcnh37ez5aYgEQz7ChcNLXetZFqj6pyPEQIgJvGQM7nvkFRz3bqE3IyrH4wAgzJMdr5fDnuOhUsFWcE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":17852},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"dbe77dade2522a37f408a2f6e5c3d8edea108e22","scripts":{"build":"tsc","prepublishOnly":"npm run build"},"_npmUser":{"name":"dakohhh","email":"wisdomdakoh@gmail.com"},"repository":{"url":"git+https://github.com/dakohhh/mongoose-paginator.git","type":"git"},"_npmVersion":"10.8.2","description":"Mongoose-Class-Paginator is a lightweight, flexible, and TypeScript-friendly pagination utility for Mongoose models. It provides a class-based approach to handling database pagination with support for filtering, sorting, population, projection, and metada","directories":{},"_nodeVersion":"20.17.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.2","@types/node":"^22.13.11"},"peerDependencies":{"mongoose":"^8.13.2","@types/mongoose":"^5.11.96"},"_npmOperationalInternal":{"tmp":"tmp/mongoose-paginator_1.0.3_1744348210227_0.6170973736562719","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@dakohhh/mongoose-paginator","version":"1.0.4","keywords":["mongoose","pagination","paginator","mongoose-pagination","typescript","mongo","mongodb","mongoose-paginator","paginate","class-based","lean","mongoose-query","data-pagination","nodejs","rest-api","graphql","mongoose-utility"],"author":{"name":"Wisdom Dakoh"},"license":"ISC","_id":"@dakohhh/mongoose-paginator@1.0.4","maintainers":[{"name":"dakohhh","email":"wisdomdakoh@gmail.com"}],"homepage":"https://github.com/dakohhh/mongoose-paginator#readme","bugs":{"url":"https://github.com/dakohhh/mongoose-paginator/issues"},"dist":{"shasum":"a97a12e8574570af902154bcaad79e66a4666ca4","tarball":"https://registry.npmjs.org/@dakohhh/mongoose-paginator/-/mongoose-paginator-1.0.4.tgz","fileCount":6,"integrity":"sha512-mUl78/dq63npnfrhf7kfkMExMY4txheG7pdIev8lHXQF3n5j5YOMFAIRUzpya9tymM1Hq1colh3p5KF7kAoH9Q==","signatures":[{"sig":"MEQCIA1xDlzwFJa6hf+1EzHnGzs82pnSYUBDJysx6BUIXaJ0AiBxVq60GtRuxnij1Mb9NQOwS9Mq8yrXPigQG4D6oXg4CQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":30187},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"dbe77dade2522a37f408a2f6e5c3d8edea108e22","scripts":{"build":"tsc","prepublishOnly":"npm run build"},"_npmUser":{"name":"dakohhh","email":"wisdomdakoh@gmail.com"},"repository":{"url":"git+https://github.com/dakohhh/mongoose-paginator.git","type":"git"},"_npmVersion":"10.8.2","description":"Mongoose-Class-Paginator is a lightweight, flexible, and TypeScript-friendly pagination utility for Mongoose models. It provides a class-based approach to handling database pagination with support for filtering, sorting, population, projection, and metada","directories":{},"_nodeVersion":"20.17.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.2","@types/node":"^22.13.11"},"peerDependencies":{"mongoose":"^8.13.2","@types/mongoose":"^5.11.96"},"_npmOperationalInternal":{"tmp":"tmp/mongoose-paginator_1.0.4_1744994974167_0.1785645701865568","host":"s3://npm-registry-packages-npm-production"}},"1.0.5":{"name":"@dakohhh/mongoose-paginator","version":"1.0.5","keywords":["mongoose","pagination","paginator","mongoose-pagination","typescript","mongo","mongodb","mongoose-paginator","paginate","class-based","lean","mongoose-query","data-pagination","nodejs","rest-api","graphql","mongoose-utility"],"author":{"name":"Wisdom Dakoh"},"license":"ISC","_id":"@dakohhh/mongoose-paginator@1.0.5","maintainers":[{"name":"dakohhh","email":"wisdomdakoh@gmail.com"}],"homepage":"https://github.com/dakohhh/mongoose-paginator#readme","bugs":{"url":"https://github.com/dakohhh/mongoose-paginator/issues"},"dist":{"shasum":"a5d71e3ac47ff5a0bf4b394e068a96b041a095cb","tarball":"https://registry.npmjs.org/@dakohhh/mongoose-paginator/-/mongoose-paginator-1.0.5.tgz","fileCount":6,"integrity":"sha512-bJZutQVLOHowQ7nyvW3rH7UFBH+BRclSeWA9aqj/iEpfS//ahJpsVtvELhY7+TgsDONs0uOtM8mWTVl6UcYDXQ==","signatures":[{"sig":"MEYCIQChQEXXYtlPZ5v5XCQUiCv1b67yRgoMyrNNyohOXom21wIhALbw0CVdeFqC4vayTP6w6v16SLYlLFi9ZpGrNK7sfuf6","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":30242},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"b86e70f959fe005e155355397ee10474d3201af0","scripts":{"build":"tsc","prepublishOnly":"npm run build"},"_npmUser":{"name":"dakohhh","email":"wisdomdakoh@gmail.com"},"repository":{"url":"git+https://github.com/dakohhh/mongoose-paginator.git","type":"git"},"_npmVersion":"10.8.2","description":"Mongoose-Class-Paginator is a lightweight, flexible, and TypeScript-friendly pagination utility for Mongoose models. It provides a class-based approach to handling database pagination with support for filtering, sorting, population, projection, and metada","directories":{},"_nodeVersion":"20.17.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.2","@types/node":"^22.13.11"},"peerDependencies":{"mongoose":"^8.13.2","@types/mongoose":"^5.11.96"},"_npmOperationalInternal":{"tmp":"tmp/mongoose-paginator_1.0.5_1745033054704_0.2838078012774301","host":"s3://npm-registry-packages-npm-production"}},"1.0.6":{"name":"@dakohhh/mongoose-paginator","version":"1.0.6","description":"Mongoose-Class-Paginator is a lightweight, flexible, and TypeScript-friendly pagination utility for Mongoose models. It provides a class-based approach to handling database pagination with support for filtering, sorting, population, projection, and metada","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","prepublishOnly":"npm run build"},"devDependencies":{"@types/node":"^22.13.11","typescript":"^5.8.2"},"repository":{"type":"git","url":"git+https://github.com/dakohhh/mongoose-paginator.git"},"keywords":["mongoose","pagination","paginator","mongoose-pagination","typescript","mongo","mongodb","mongoose-paginator","paginate","class-based","lean","mongoose-query","data-pagination","nodejs","rest-api","graphql","mongoose-utility"],"author":{"name":"Wisdom Dakoh"},"license":"ISC","bugs":{"url":"https://github.com/dakohhh/mongoose-paginator/issues"},"homepage":"https://github.com/dakohhh/mongoose-paginator#readme","peerDependencies":{"@types/mongoose":"^5.11.96","mongoose":"^8.13.2"},"_id":"@dakohhh/mongoose-paginator@1.0.6","gitHead":"b86e70f959fe005e155355397ee10474d3201af0","_nodeVersion":"20.17.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-Zd+ljURI6VvqfqYl+z5+5xcq1UN1tPHHmQR3U7nK9DW5S1pHFOhbkgQnYkHtjHYX4buAEPOtDmdB2BHcr2VDYw==","shasum":"f2cb64c709fddaa3e421554d89b65af48171f340","tarball":"https://registry.npmjs.org/@dakohhh/mongoose-paginator/-/mongoose-paginator-1.0.6.tgz","fileCount":6,"unpackedSize":32954,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCtlTpp+CGo1Pd7dMffEL7CmxBn662r2UsX+KqtP4+gNgIgASy701GfUYW6LirT2kfZhgPq84lnwOOg9axUEXxDCFQ="}]},"_npmUser":{"name":"dakohhh","email":"wisdomdakoh@gmail.com"},"directories":{},"maintainers":[{"name":"dakohhh","email":"wisdomdakoh@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mongoose-paginator_1.0.6_1756637187941_0.9280792520962668"},"_hasShrinkwrap":false}},"time":{"created":"2025-04-05T11:33:41.117Z","modified":"2025-08-31T10:46:28.340Z","1.0.0":"2025-04-05T11:33:41.386Z","1.0.1":"2025-04-05T11:47:43.995Z","1.0.2":"2025-04-08T21:48:23.213Z","1.0.3":"2025-04-11T05:10:10.425Z","1.0.4":"2025-04-18T16:49:34.373Z","1.0.5":"2025-04-19T03:24:14.937Z","1.0.6":"2025-08-31T10:46:28.146Z"},"bugs":{"url":"https://github.com/dakohhh/mongoose-paginator/issues"},"author":{"name":"Wisdom Dakoh"},"license":"ISC","homepage":"https://github.com/dakohhh/mongoose-paginator#readme","keywords":["mongoose","pagination","paginator","mongoose-pagination","typescript","mongo","mongodb","mongoose-paginator","paginate","class-based","lean","mongoose-query","data-pagination","nodejs","rest-api","graphql","mongoose-utility"],"repository":{"type":"git","url":"git+https://github.com/dakohhh/mongoose-paginator.git"},"description":"Mongoose-Class-Paginator is a lightweight, flexible, and TypeScript-friendly pagination utility for Mongoose models. It provides a class-based approach to handling database pagination with support for filtering, sorting, population, projection, and metada","maintainers":[{"name":"dakohhh","email":"wisdomdakoh@gmail.com"}],"readme":"# @dakohhh/mongoose-paginator\n\n[![npm version](https://img.shields.io/npm/v/@dakohhh/mongoose-paginator.svg)](https://www.npmjs.com/package/@dakohhh/mongoose-paginator)\n[![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC)\n\nA lightweight, flexible, and TypeScript-friendly pagination utility for Mongoose models. This package provides a class-based approach to handling database pagination with support for filtering, sorting, population, projection, and metadata customization — all without relying on heavy plugins.\n\n## Features\n\n- 🚀 **Lightweight & Performant**: Minimal overhead with optimized query execution\n- 🔧 **Fully Configurable**: Customize filters, sorting, projections, and more\n- 📊 **Rich Metadata**: Comprehensive pagination metadata including total count, page info, and navigation\n- 🧩 **Fluent API**: Chainable methods for a clean and intuitive interface\n- 📝 **TypeScript Support**: Full type safety with generic typing\n- 🔄 **Document/JSON Flexibility**: Support for both Mongoose documents and lean objects\n- 🔍 **Advanced Querying**: Compatible with all Mongoose query operators\n- 🧪 **Zero Dependencies**: No external dependencies beyond Mongoose\n\n## Installation\n\n```bash\nnpm install @dakohhh/mongoose-paginator\n```\n\nOr with yarn:\n\n```bash\nyarn add @dakohhh/mongoose-paginator\n```\n\n## Usage\n\n> **⚠️ Deprecation Notice:**\n> \n> The `Paginator` class has been **deprecated** and will be removed in a future release. Please use the `PageNumberPaginator` class instead. `PageNumberPaginator` is functionally identical to `Paginator` and is now the recommended way to perform page-number-based pagination.\n> \n> ```typescript\n> import { PageNumberPaginator } from '@dakohhh/mongoose-paginator';\n> // Usage is identical to the old Paginator class.\n> ```\n\n### Basic Example\n\n```typescript\nimport { Paginator } from '@dakohhh/mongoose-paginator';\nimport { model, Schema, Document } from 'mongoose';\n\n// Define your Mongoose model\ninterface IUser extends Document {\n  name: string;\n  email: string;\n  age: number;\n  createdAt: Date;\n}\n\nconst UserModel = model<IUser>('User', userSchema);\n\n// Create a paginator instance\nconst paginator = new Paginator<IUser>(UserModel);\n\n// Execute pagination\nconst result = await paginator.paginate();\n\nconsole.log(result);\n// Output: { data: [...], meta: { total, lastPage, currentPage, perPage, prev, next } }\n\n// You can also destructure the results for cleaner code\nconst { data: users, meta: paginationInfo } = await paginator.paginate();\nconsole.log(users); // Array of user documents\nconsole.log(paginationInfo); // Pagination metadata\n```\n\n### Advanced Usage\n\n#### Page Number Pagination (Recommended)\n\n```typescript\nimport { PageNumberPaginator } from '@dakohhh/mongoose-paginator';\n\nconst page = 1\nconst limit = 10\nconst paginator = new PageNumberPaginator<IUser>(UserModel, page, limit, {\n  filter: { age: { $gte: 18 } },\n  sort: { createdAt: -1 },\n  projection: ['name', 'email', '-_id'],\n  populate: [{ path: 'posts', select: 'title' }],\n  lean: true\n});\n\nconst result = await paginator.paginate();\nconsole.log(result);\n// {\n//   data: [...],\n//   meta: { total, lastPage, currentPage, perPage, prev, next }\n// }\n```\n\n#### Offset Pagination\n\nOffset-based pagination is useful for traditional skip-limit pagination scenarios.\n\n```typescript\nimport { OffsetPaginator } from '@dakohhh/mongoose-paginator';\n\nconst offset = 0; // Start offset\nconst limit = 10; // Items per page\nconst paginator = new OffsetPaginator<IUser>(UserModel, offset, limit, {\n  filter: { age: { $gte: 18 } },\n  sort: { createdAt: -1 },\n  projection: ['name', 'email', '-_id'],\n  populate: [{ path: 'posts', select: 'title' }],\n  lean: true\n});\n\nconst result = await paginator.paginate();\nconsole.log(result);\n// {\n//   data: [...],\n//   meta: { total, lastPage, currentPage, perPage, prev, next }\n// }\n```\n\n#### Cursor Pagination\n\nCursor-based pagination is ideal for real-time feeds or infinite scrolling. Use the `nextCursor` from the previous result to fetch the next page.\n\n```typescript\nimport { CursorPaginator } from '@dakohhh/mongoose-paginator';\n\nlet cursor: string | null = null; // BSON ObjectId\nconst limit = 10;\nconst paginator = new CursorPaginator<IUser>(UserModel, cursor, limit, {\n  filter: { age: { $gte: 18 } },\n  projection: ['name', 'email', '-_id'],\n  populate: [{ path: 'posts', select: 'title' }],\n  lean: true\n});\n\nconst result = await paginator.paginate();\nconsole.log(result);\n// {\n//   data: [...],\n//   meta: { nextCursor }\n// }\n\n// To fetch the next page:\ncursor = result.meta.nextCursor;\nconst nextPage = await new CursorPaginator<IUser>(UserModel, cursor, limit).paginate();\n```\n\n---\n\n### Result Customization\n\nOne of the key advantages of this paginator is the ability to easily customize how you access your results through destructuring:\n\n```typescript\n// Standard result object\nconst result = await paginator.paginate();\n\n// Customize variable names through destructuring\nconst { data: users, meta: paginationInfo } = await paginator.paginate();\n\n// Access your data with your preferred variable names\nconsole.log(users); // Your paginated documents with your custom name\nconsole.log(paginationInfo.currentPage); // Access pagination metadata with your custom name\n\n// Use in a response object\nreturn {\n  success: true,\n  users, // Your renamed data array\n  pagination: paginationInfo // Your renamed metadata\n};\n```\n\n## API Reference\n\n### `Paginator<T>`\n\nThe main class for pagination operations.\n\n#### Constructor\n\n```typescript\nconstructor(\n  model: Model<T>,\n  page: number = 1,\n  limit: number = 10,\n  args: IPaginateArgs<T> = { filter: {}, sort: { createdAt: -1 }, lean: true }\n)\n```\n\n#### Methods\n\n- **`paginate()`**: Executes the pagination query and returns results with metadata\n- **`setPage(page: number)`**: Sets the current page number\n- **`setLimit(limit: number)`**: Sets the number of items per page\n- **`setArgs(args: IPaginateArgs<T>)`**: Sets the query arguments\n\n### Interfaces\n\n#### `IPaginateArgs<T>`\n\n```typescript\ninterface IPaginateArgs<T> {\n  filter?: FilterQuery<T>;\n  sort?: Record<string, SortOrder>;\n  projection?: string | string[] | Record<string, number | boolean | string | object>;\n  populate?: PopulateOptions | PopulateOptions[];\n  lean?: boolean;\n}\n```\n\n#### `IPaginationResult<T>`\n\n```typescript\ninterface IPaginationResult<T> {\n  data: T[];\n  meta: IPaginationMeta;\n}\n```\n\n#### `IPaginationMeta`\n\n```typescript\ninterface IPaginationMeta {\n  total: number;\n  lastPage: number;\n  currentPage: number;\n  perPage: number;\n  prev: number | null;\n  next: number | null;\n}\n```\n\n## Advantages Over Other Solutions\n\n- **Class-Based Design**: Unlike function-based pagination utilities, our class-based approach allows for a more intuitive and chainable API.\n\n- **TypeScript First**: Built with TypeScript from the ground up, providing complete type safety without compromising on features.\n\n- **Lightweight**: No external dependencies beyond Mongoose itself, making it a lightweight addition to your project.\n\n- **Flexible Query Options**: Full support for all Mongoose query capabilities including complex filtering, sorting, and population.\n\n- **Performance Optimized**: Uses `Promise.all` to run document fetching and count queries in parallel for better performance.\n\n- **Lean Option**: Built-in support for lean queries, significantly improving performance when working with large datasets.\n\n- **Comprehensive Metadata**: Provides rich pagination metadata including total count, current page, last page, and navigation helpers.\n\n- **Fluent API**: Chainable methods make the API intuitive and easy to use, improving code readability.\n\n## Use Cases\n\n- **RESTful APIs**: Implement standardized pagination for your API endpoints\n- **Admin Dashboards**: Paginate large datasets in admin interfaces\n- **Data Tables**: Power data tables with server-side pagination\n- **Search Results**: Paginate search results efficiently\n- **Feed Systems**: Implement \"load more\" or paginated content feeds\n\n\n## 🔄 Comparison: `@dakohhh/mongoose-paginator` vs `mongoose-paginate-v2`\n\n| Feature                  | @dakohhh/mongoose-paginator                                                                 | mongoose-paginate-v2                                |\n|--------------------------|---------------------------------------------------------------------------------------------|-----------------------------------------------------|\n| 🏗️ Architecture          | Class-based with fluent, chainable methods                                                  | Plugin-based (requires schema.plugin)               |\n| ✅ TypeScript Support     | ✅ First-class TypeScript support with full generic typing                                  | ⚠️ Partial — requires community types                |\n| 🧩 Integration            | No schema modification needed — use directly with any Mongoose model                       | Requires modification via schema.plugin             |\n| 🚀 Performance            | Parallel execution of data & count queries using `Promise.all()`                           | Serial execution (slightly slower on large queries) |\n| 🧠 Query Options          | Advanced support: filtering, sorting, projection, population, lean queries                 | Basic support for filter, select, populate, lean    |\n| 📊 Pagination Metadata    | Rich meta: total, perPage, currentPage, prev, next, lastPage                               | Provides basic pagination metadata                  |\n| 🔄 Chainable API          | ✅ Fluent API: `.setPage().setLimit().setArgs()`                                            | ❌ Not supported                                     |\n| 🧼 Clean API              | Supports destructuring (`const { data, meta } = ...`)                                      | Partially supported                                 |\n| 🧪 Testability            | Easily testable: no schema mutation, class-based structure                                 | Harder to mock due to schema plugin requirement     |\n| ⚙️ Projection Support     | ✅ Yes                                                                                      | ✅ Yes                                               |\n| 🔌 Populate Support       | ✅ Yes                                                                                      | ✅ Yes                                               |\n| 💬 Lean Document Support  | ✅ Yes                                                                                      | ✅ Yes                                               |\n| 📦 Dependencies           | Zero dependencies beyond Mongoose                                                          | Depends on Mongoose and plugin structure            |\n| 🧠 Learning Curve         | Slightly higher (class-based, customizable)                                                | Very beginner-friendly                              |\n| 📚 Community              | New and growing                                                                             | Large and established                               |\n| 🔐 Schema Safety          | Does not modify original schema                                                             | Alters schema with plugin                           |\n\n---\n\n## License\n\nISC\n\n## Author\n\nWisdom Dakoh\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n","readmeFilename":"README.md"}