{"id":31228504,"url":"https://github.com/eronmmer/ottoman-paginate","last_synced_at":"2025-09-22T06:57:10.612Z","repository":{"id":57316846,"uuid":"350141536","full_name":"Eronmmer/ottoman-paginate","owner":"Eronmmer","description":"A simple pagination library for Ottoman.js with custom labels. ⚡","archived":false,"fork":false,"pushed_at":"2025-07-07T18:12:31.000Z","size":297,"stargazers_count":21,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-17T00:23:01.243Z","etag":null,"topics":["couchbase","customizable-labels","document","library","metadata","n1ql","ottoman","paginate","pagination","pagination-library","plugin"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/ottoman-paginate","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Eronmmer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-21T22:59:46.000Z","updated_at":"2025-07-07T18:12:35.000Z","dependencies_parsed_at":"2022-08-25T20:31:58.310Z","dependency_job_id":null,"html_url":"https://github.com/Eronmmer/ottoman-paginate","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/Eronmmer/ottoman-paginate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eronmmer%2Fottoman-paginate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eronmmer%2Fottoman-paginate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eronmmer%2Fottoman-paginate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eronmmer%2Fottoman-paginate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Eronmmer","download_url":"https://codeload.github.com/Eronmmer/ottoman-paginate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eronmmer%2Fottoman-paginate/sbom","scorecard":{"id":46639,"data":{"date":"2025-08-11","repo":{"name":"github.com/Eronmmer/ottoman-paginate","commit":"9a4ccbf8fcfec8e25e53230049140a44bd73c89d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.6,"checks":[{"name":"Maintained","score":7,"reason":"9 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 7","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Code-Review","score":0,"reason":"Found 0/18 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":7,"reason":"3 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-14T22:54:59.314Z","repository_id":57316846,"created_at":"2025-08-14T22:54:59.314Z","updated_at":"2025-08-14T22:54:59.314Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276361175,"owners_count":25628853,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-22T02:00:08.972Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["couchbase","customizable-labels","document","library","metadata","n1ql","ottoman","paginate","pagination","pagination-library","plugin"],"created_at":"2025-09-22T06:57:09.169Z","updated_at":"2025-09-22T06:57:10.606Z","avatar_url":"https://github.com/Eronmmer.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ottoman Paginate 🍨\n\n## Introduction\n\nThis Plugin, inspired by [mongoose-paginate](https://github.com/aravindnc/mongoose-paginate-v2), offers a simple, yet elegant way to implement pagination with Ottoman.js. You can also alter the return value keys directly in the query itself so that you don't need any extra code for transformation.\n\n## Installation\n\n```sh\nyarn add ottoman-paginate\n```\n\n## Usage\n\nAdd the plugin to a schema and then use the `paginate` method:\n\n```js\nconst { model, Schema } = require(\"ottoman\");\nconst ottomanPaginate = require(\"ottoman-paginate\");\n\nconst person = new Schema({\n  name: String,\n});\n\nperson.plugin(ottomanPaginate);\n\nconst PersonModel = model(\"Person\", issueSchema);\n\nPersonModel.paginate().then({}); // Usage\n```\n\n### Model.paginate([filter], [options], [callback])\n\nReturns a promise\n\n**Parameters**\n\n- `[filter]` {Object} - Filter Query. [Documentation](https://v2.ottomanjs.com/globals.html#logicalwhereexpr)\n- `[options]` {Object} - Options passed to Ottoman's [find() function](https://v2.ottomanjs.com/classes/findoptions.html#class-findoptions) along with other custom options for pagination.\n  - `[select]` {string | string[]} - Fields to return (returns all fields by default). [Documentation](https://v2.ottomanjs.com/classes/findoptions.html#optional-select)\n  - `[sort]` {string} - Sort order. [Documentation](https://v2.ottomanjs.com/classes/findoptions.html#optional-sort)\n  - `[populate]` {string | string[]} - Paths which should be populated with other documents. [Documentation](https://v2.ottomanjs.com/guides/document.html#populate)\n  - `[lean]` {Boolean}\n  - `[consistency]` {SearchConsistency} - [Documentation](https://v2.ottomanjs.com/classes/findoptions.html#optional-consistency)\n  - `[noCollection]` {undefined | Boolean} - [Documentation](https://v2.ottomanjs.com/classes/findoptions.html#optional-nocollection)\n  - `[populateMaxDeep]` {undefined | number} - [Documentation](https://v2.ottomanjs.com/classes/findoptions.html#optional-populatemaxdeep)\n  - `[ottomanMetaData=true]` {Boolean} - If `ottomanMetaData` is set to false, it will not include the `meta` property that is usually present in the response object of Ottoman's `find()` function.\n  - `[offset=0]` {Number} - Use `offset` or `page` to set skip position\n  - `[page=1]` {Number}\n  - `[limit=10]` {Number}\n  - `[customLabels]` {Object} - Add custom labels to manipulate the response data.\n  - `[pagination]` {Boolean} - If `pagination` is set to false, it will return all docs without adding limit condition. (Default: True)\n- `[callback(err, result)]` - If specified, the callback is called once pagination results are retrieved or when an error has occurred.\n\n**Return value**\n\nPromise fulfilled with object having properties:\n\n- `docs` {Array} - Array of documents\n- `totalDocs` {Number} - Total number of documents in collection that match a query\n- `limit` {Number} - Limit that was used\n- `hasPrevPage` {Bool} - Availability of previous page.\n- `hasNextPage` {Bool} - Availability of next page.\n- `page` {Number} - Current page number.\n- `totalPages` {Number} - Total number of pages.\n- `offset` {Number} - Only if specified or default `page`/`offset` values were used\n- `prevPage` {Number} - Previous page number if available or `null`\n- `nextPage` {Number} - Next page number if available or `null`\n- `pagingCounter` {Number} -  The starting index number of the first document in the current page.\n- `meta` {Object} - Request meta data from Ottoman.\n- `paginationMetaData` {Object} - Object of pagination meta data (Disabled by default).\n\nThe above properties can be renamed by setting customLabels attribute.\n\n### Sample Usage\n\nThe following returns the first 10 documents from a collection of 100 documents.\n\n```javascript\nconst options = {\n  page: 1,\n  limit: 10,\n};\n\nModel.paginate({}, options, function (err, result) {\n  // result.docs\n  // result.totalDocs = 100\n  // result.limit = 10\n  // result.page = 1\n  // result.totalPages = 10\n  // result.hasNextPage = true\n  // result.nextPage = 2\n  // result.hasPrevPage = false\n  // result.prevPage = null\n  // result.pagingCounter = 1\n  // result.meta\n});\n```\n\n### With custom return labels\n\nYou can change the name of the following attributes\n\n- totalDocs\n- docs\n- limit\n- page\n- nextPage\n- prevPage\n- hasNextPage\n- hasPrevPage\n- totalPages\n- pagingCounter\n- paginationMetaData\n\nYou should pass the names of the properties you wish to change using `customLabels` object in options.\nSet the property to false to remove it from the result.\nBelow is a query with custom labels.\n\n```javascript\nconst myCustomLabels = {\n  totalDocs: \"itemCount\",\n  docs: \"itemsList\",\n  limit: \"perPage\",\n  page: \"currentPage\",\n  nextPage: \"next\",\n  prevPage: \"prev\",\n  totalPages: \"pageCount\",\n  pagingCounter: \"slNo\",\n  paginationMetaData: \"paginator\",\n};\n\nconst options = {\n  page: 1,\n  limit: 10,\n  customLabels: myCustomLabels,\n};\n\nModel.paginate({}, options, function (err, result) {\n  // result.itemsList [here docs becomes itemsList]\n  // result.paginator.itemCount = 100 [here totalDocs becomes itemCount]\n  // result.paginator.perPage = 10 [here limit becomes perPage]\n  // result.paginator.currentPage = 1 [here page becomes currentPage]\n  // result.paginator.pageCount = 10 [here totalPages becomes pageCount]\n  // result.paginator.next = 2 [here nextPage becomes next]\n  // result.paginator.prev = null [here prevPage becomes prev]\n  // result.paginator.slNo = 1 [here pagingCounter becomes slNo]\n  // result.paginator.hasNextPage = true\n  // result.paginator.hasPrevPage = false\n});\n```\n\n### Other Examples\n\nUsing `offset` and `limit`:\n\n```javascript\nModel.paginate({}, { offset: 30, limit: 10 }, function (err, result) {\n  // result.docs\n  // result.totalPages\n  // result.limit - 10\n  // result.offset - 30\n});\n```\n\nWith promise:\n\n```js\nModel.paginate({}, { offset: 30, limit: 10 }).then(function (result) {\n  // ...\n});\n```\n\n#### Adding more options\n\n```javascript\nvar filter = {};\nvar options = {\n  select: \"title date author\",\n  sort: { date: \"DESC\" },\n  populate: \"author\",\n  offset: 20,\n  limit: 10,\n  ottomanMetaData: false,\n};\n\nBook.paginate(filter, options).then(function (result) {\n  // ...\n});\n```\n\n#### Zero limit\n\nYou can use `limit=0` to get only the pagination metadata:\n\n```javascript\nModel.paginate({}, { limit: 0 }).then(function (result) {\n  // result.docs - empty array\n  // result.totalDocs\n  // result.limit - 0\n});\n```\n\n#### Fetch all docs without pagination.\n\nIf you need to fetch all the documents in the collection without applying a limit. Then set the `pagination` option to false,\n\n```javascript\nconst options = {\n  pagination: false,\n};\n\nModel.paginate({}, options, function (err, result) {\n  // result.docs\n  // result.totalDocs = 100\n  // result.limit = 100\n  // result.page = 1\n  // result.totalPages = 1\n  // result.hasNextPage = false\n  // result.nextPage = null\n  // result.hasPrevPage = false\n  // result.prevPage = null\n  // result.pagingCounter = 1\n});\n```\n\n## Contribution\n\nIf you find an issue with the package or want to add a nice feature, create an issue or submit a PR.\n\n## Test\n\n- Create an `.env` file with your required variables. Check `.example.env` to see how it's done.\n- Run the following command.\n\n```sh\nyarn test\n```\n\n## Todo\n\n- Rewrite with TS and include types\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feronmmer%2Fottoman-paginate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feronmmer%2Fottoman-paginate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feronmmer%2Fottoman-paginate/lists"}