{"id":13676735,"url":"https://github.com/limit-zero/mongoose-graphql-pagination","last_synced_at":"2025-08-21T15:43:02.332Z","repository":{"id":93581296,"uuid":"132174039","full_name":"limit-zero/mongoose-graphql-pagination","owner":"limit-zero","description":"GraphQL cursor pagination (Relay-like) for Mongoose models.","archived":false,"fork":false,"pushed_at":"2022-08-14T14:49:39.000Z","size":93,"stargazers_count":32,"open_issues_count":1,"forks_count":10,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-08-08T19:04:06.657Z","etag":null,"topics":["apollo-server","autocomplete","cursor","elasticsearch","graphql","mongodb","mongoose","nodejs","pagination"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/limit-zero.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-05-04T18:13:22.000Z","updated_at":"2023-12-01T07:15:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"d95433c0-419e-4df8-b2d5-32763828ab44","html_url":"https://github.com/limit-zero/mongoose-graphql-pagination","commit_stats":{"total_commits":92,"total_committers":2,"mean_commits":46.0,"dds":0.04347826086956519,"last_synced_commit":"1355d26cc731b63e3f39f829d12994521cac23e6"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/limit-zero/mongoose-graphql-pagination","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limit-zero%2Fmongoose-graphql-pagination","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limit-zero%2Fmongoose-graphql-pagination/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limit-zero%2Fmongoose-graphql-pagination/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limit-zero%2Fmongoose-graphql-pagination/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/limit-zero","download_url":"https://codeload.github.com/limit-zero/mongoose-graphql-pagination/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limit-zero%2Fmongoose-graphql-pagination/sbom","scorecard":{"id":590177,"data":{"date":"2025-08-11","repo":{"name":"github.com/limit-zero/mongoose-graphql-pagination","commit":"1355d26cc731b63e3f39f829d12994521cac23e6"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.1,"checks":[{"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":"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":"Code-Review","score":1,"reason":"Found 2/11 approved changesets -- score normalized to 1","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":"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":"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":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"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":"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":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 26 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"60 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-6chw-6frg-f759","Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx","Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-4jwp-vfvf-657p","Warn: Project is vulnerable to: GHSA-v8w9-2789-6hhr","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5","Warn: Project is vulnerable to: GHSA-q42p-pg8m-cqh6","Warn: Project is vulnerable to: GHSA-w457-6q6x-cgp9","Warn: Project is vulnerable to: GHSA-62gr-4qp9-h98f","Warn: Project is vulnerable to: GHSA-f52g-6jhx-586p","Warn: Project is vulnerable to: GHSA-2cf5-4w76-r9qv","Warn: Project is vulnerable to: GHSA-3cqr-58rm-57f8","Warn: Project is vulnerable to: GHSA-g9r4-xpmj-mj65","Warn: Project is vulnerable to: GHSA-q2c6-c6pm-g3gh","Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44","Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-2pr6-76vf-7546","Warn: Project is vulnerable to: GHSA-8j8c-7jfh-h6hx","Warn: Project is vulnerable to: GHSA-675m-85rw-j3w4","Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp","Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574","Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm","Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-fhjf-83wg-r2j9","Warn: Project is vulnerable to: GHSA-mh5c-679w-hh4r","Warn: Project is vulnerable to: GHSA-8687-vv9j-hgph","Warn: Project is vulnerable to: GHSA-f825-f98c-gj3g","Warn: Project is vulnerable to: GHSA-h8hf-x3f4-xwgp","Warn: Project is vulnerable to: GHSA-9m93-w8w6-76hh","Warn: Project is vulnerable to: GHSA-m7xq-9374-9rvx","Warn: Project is vulnerable to: GHSA-vg7j-7cwx-8wgw","Warn: Project is vulnerable to: GHSA-p92x-r36w-9395","Warn: Project is vulnerable to: GHSA-45q2-34rf-mr94","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-g6ww-v8xp-vmwg","Warn: Project is vulnerable to: GHSA-6g33-f262-xjp4","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-4g88-fppr-53pp","Warn: Project is vulnerable to: GHSA-4jqc-8m5r-9rpr","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"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-20T21:39:31.654Z","repository_id":93581296,"created_at":"2025-08-20T21:39:31.654Z","updated_at":"2025-08-20T21:39:31.654Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271502432,"owners_count":24770869,"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-08-21T02:00:08.990Z","response_time":74,"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":["apollo-server","autocomplete","cursor","elasticsearch","graphql","mongodb","mongoose","nodejs","pagination"],"created_at":"2024-08-02T13:00:31.957Z","updated_at":"2025-08-21T15:43:02.300Z","avatar_url":"https://github.com/limit-zero.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# GraphQL Mongoose Cursor Pagination with Elasticsearch Support\nAdds support for Relay-like cursor pagination with Mongoose models/documents. This library also provides type-ahead (autocomplete) functionality (with pagination) using MongoDB regular expression queries. In addition, you can optionally paginate hydrated Mongoose models from Elasticsearch.\n\n## Install\n`yarn add @limit0/mongoose-graphql-pagination`\n\n## Usage\nPagination, type-ahead, and Elastic+Mongoose pagination support are available via the `Pagination`, `TypeAhead` and `SearchPagination` classes, respectively. **All classes should be considered, \"single use,\" and should be instantiated once per query or request.**\n\n### Pagination\nReturns paginated results from MongoDB for the provided Mongoose model.\n\n To begin using, require the class\n```js\nconst { Pagination } = require('@limit0/mongoose-graphql-pagination');\n```\nUse the class constructor to configure the settings for the paginated query.\n\n#### constructor(Model, { criteria = {}, pagination = {}, sort = {}, projection }, options = {})\n`Model`: The Mongoose model instance to query. _Required._\n\n`criteria`: A query criteria object to apply to the paginated query. Can be any MongoDB query. For example: `{ deleted: false }` or `{ age: { $gt: 30 } }`. The criteria will be deeply merged, but will ignore \"special\" objects such as `ObjectId` and, by default, will only merge \"plain objects.\" Optional.\n\n`pagination`: The pagination parameters object. Can accept a `first` and/or `after` property. The `first` value specifies the limit/page size. The `after` value specifies the cursor to start at when paginating. For example: `{ first: 50, after: 'some-cursor-value' }` would return the first 50 edges after the provided cursor. By default the results will be limited to 10 edges. Optional.\n\n`sort`: Specifies the sort options. The `field` property specifies the field to sort by, and the order defines the direction. For example: `{ field: 'name', order: -1 }` would sort the edges by name, descending. By default the edges are sorted by ID, ascending. Optional.\n\n`projection`: Specifies the fields to return from the database. For example: `{ field: 1 }` or `{ field: 0 }` would include or exclude the specified field, respectively. If left `undefined`, or as an empty object, all fields will be returned (which is the default behavior). Optional.\n\n`options`: Specifies additional configuration options, such as default limit, max limit, sort collation, object merge options, and sort created field.\n\nComplete example:\n```js\nconst { Pagination } = require('@limit0/mongoose-graphql-pagination');\nconst YourModel = require('./your-model');\n\nconst paginated = new Pagination(YourModel, {\n  criteria: { deleted: false },\n  pagination: { first: 25 },\n  sort: { field: 'name', order: -1 },\n});\n// Retrieve the edges...\nconst edges = paginated.getEdges();\n```\n\nOnce the instance is created, use the methods listed below to access the paginated info.\n\n#### getTotalCount()\nReturns the total number of documents that match the query criteria, regardless of page size (limit).\n\n#### getEdges()\nReturns the edges (Mongoose document nodes) that match the query criteria. The results will be limited by the `first` value.\n\n#### getEndCursor()\nReturns the cursor value (non-obfuscated) of the last edge that matches the current criteria. This value will resolve to the Mongoose document ID, and can be converted into an obfuscated ID when returned by the GraphQL server. Will return `null` if no results were found.\n\n#### hasNextPage()\nDetermines if another page of edges is available, based on the current criteria.\n\n### Type-Ahead (Auto Complete)\nType ahead support is implemented using MongoDB regular expression queries. To begin using, require the class:\n```js\nconst { TypeAhead } = require('@limit0/mongoose-graphql-pagination');\n```\nUse the class constructor to configure the settings for the type-ahead query.\n\n#### constructor(field, term, criteria = {}, options = {})\n`field`: The field to query/search against. For example: `name`. _Required._\n\n`term`: The search term. Can/should be a partial phrase. _Required._\n\n`criteria`: Additional MongoDB query criteria to apply when querying. For example `{ deleted: false }`. The criteria will be deeply merged, but will ignore \"special\" objects such as `ObjectId` and, by default, will only merge \"plain objects.\" Optional.\n\n`options`: The type-ahead configuration options object. Has three type-ahead related properties:\n```js\n{\n  // Determines how the regex is constructed.\n  // Can either be `starts-with`, `ends-with`, `exact-match` or `contains`.\n  // Defaults to `contains`.\n  position: 'contains',\n  // Whether to escape regex special characters.\n  // Defaults to `true`.\n  escape: true,\n  // Whether to treat the regex query as case sensitive.\n  // Defaults to `false`.\n  caseSensitive: false,\n}\n```\nIn addition, the `options` will also accept the optional `mergeOptions` object property htat can be used to override the default merge rules.\n\n#### paginate(Model, pagination = {}, options = {})\nCreates a `Pagination` instance using the constructed `TypeAhead` options.\n\n#### buildCriteria()\nReturns the MongoDB criteria that can be used for querying the database. Generally, this will not be used and, instead, should be indirectly accessed via the `paginate` method.\n\nComplete example:\n```js\nconst { TypeAhead } = require('@limit0/mongoose-graphql-pagination');\nconst YourModel = require('./your-model');\n\nconst typeahead = new TypeAhead('name', 'foo', {\n  deleted: false,\n}, {\n  position: 'starts-with',\n});\nconst paginated = typeahead.paginate(YourModel, { first: 25 });\n// Retrieve the edges...\nconst edges = paginated.getEdges();\n```\n\n### Search Pagination\nReturns paginated and hydrated Mongoose/MongoDB results from Elasticsearch. This assumes that you are, in some fashion, saving _some_ data for a specific Mongoose model within Elasticsearch, as this will attempt to convert the Elastic results back into Mongoose documents from MongoDB. This also assumes that the `_id` value of the indexed document in Elasticsearch matches the `_id` value that is stored in MongoDB.\n\n To begin using, require the class\n```js\nconst { SearchPagination } = require('@limit0/mongoose-graphql-pagination');\n```\nUse the class constructor to configure the settings for the paginated query.\n\n#### constructor(Model, client, { params = {}, pagination = {} })\n`Model`: The Mongoose model instance to use for re-querying MongoDB to hydrate the Elasticsearch results. _Required._\n\n`client`: The Elasticsearch client instance created from the `elasticsearch` Node/JS API library. _Required._\n\n`params`: The elastic [search parameters](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-search) that will be sent to `client.search`. For example: `{ index: 'some-index', type: 'some-type', body: { query: { match_all: {} } } }` _Required_.\n\n`pagination`: The pagination parameters object. Can accept a `first` and/or `after` property. The `first` value specifies the limit/page size. The `after` value specifies the cursor to start at when paginating. For example: `{ first: 50, after: 'some-cursor-value' }` would return the first 50 edges after the provided cursor. By default the results will be limited to 10 edges. Optional.\n\nComplete example:\n```js\nconst { SearchPagination } = require('@limit0/mongoose-graphql-pagination');\nconst elasticClient = require('./your-elasticsearch-client');\nconst YourModel = require('./your-model');\n\nconst params = {\n  index: 'your-index',\n  type: 'your-type',\n  body: {\n    query: { match_all: {} },\n  },\n};\nconst pagination = { first: 25 };\n\nconst paginated = new SearchPagination(YourModel, elasticClient, { params, pagination });\n// Retrieve the edges...\nconst edges = paginated.getEdges();\n```\n\nOnce the instance is created, use the methods listed below to access the paginated info.\n\n#### getTotalCount()\nReturns the total number of documents that match the search criteria, regardless of page size (limit).\n\n#### getEdges()\nReturns the edges (hydrated Mongoose document nodes from Elasticsearch hits) that match the search criteria. The results will be limited by the `first` value.\n\n#### getEndCursor()\nReturns the cursor value (non-obfuscated) of the last edge that matches the current criteria. This value will resolve to a JSON stringified version of the Elasticsearch `sort` value, and can be converted into an obfuscated ID when returned by the GraphQL server. Will return `null` if no results were found.\n\n#### hasNextPage()\nDetermines if another page of edges is available, based on the current criteria.\n\n### Pagination Resolvers\nFinally, the `paginationResolvers` provide helper functions for using Pagination with a GraphQL server such as Apollo.\n\nFor example, if you had a GraphQL definition similar to this:\n```graphql\nscalar Cursor\n\ntype Query {\n  allContacts(pagination: PaginationInput = {}, sort: ContactSortInput = {}): ContactConnection!\n  searchContacts(pagination: PaginationInput = {}, phrase: String!): ContactConnection!\n}\n\ntype ContactConnection {\n  totalCount: Int!\n  edges: [ContactEdge]!\n  pageInfo: PageInfo!\n}\n\ntype ContactEdge {\n  node: Contact!\n  cursor: Cursor!\n}\n\ntype Contact {\n  id: String!\n  name: String!\n  email: String!\n}\n\ntype PageInfo {\n  hasNextPage: Boolean!\n  endCursor: Cursor\n}\n\ninput PaginationInput {\n  first: Int! = 25\n  after: Cursor\n}\n\ninput ContactSortInput {\n  field: ContactSortField! = createdAt\n  order: Int! = -1\n}\n\nenum ContactSortField {\n  name\n  createdAt\n  updatedAt\n}\n```\n\nThe following resolvers could be applied:\n```js\nconst { CursorType } = require('@limit0/graphql-custom-types');\nconst { Pagination, paginationResolvers, SearchPagination } = require('@limit0/mongoose-graphql-pagination');\n\nconst elasticClient = require('./path-to/elasticsearch-client');\nconst Contact = require('./path-to/contact-model');\n\nmodule.exports = {\n  // The cursor type.\n  // Will obfuscate the MongoID for `Pagination` and the Elastic sort value for `SearchPagination`\n  Cursor: CursorType,\n\n  // Apply the pagination resolvers for the connection.\n  ContactConnection: paginationResolvers.connection,\n\n  Query: {\n    /**\n     * Use pagination on the query.\n     * Will query MongoDB via Mongoose for the provided model.\n     */\n    allContacts: (root, { pagination, sort }) =\u003e new Pagination(Contact, { pagination, sort }, {\n      // Informs the sort that the `createdAt` field specifies a created date.\n      // Will instead use the document ID when sorting.\n      sort: { createdField: 'createdAt' },\n    }),\n\n    /**\n     * Use search pagination on the query.\n     * Will query Elasticsearch and then hydrate the results from\n     * MongoDB (via Mongoose) for the provided model.\n     */\n    searchContacts: (root, { pagination, phrase }) =\u003e {\n      // Set the parameters for the elastic client `search` method.\n      // @see https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-search\n      const params = {\n        index: 'index-where-contacts-exist',\n        type: 'type-where-contacts-exist',\n        body: { query: { match: { name: phrase } } },\n      };\n      return new SearchPagination(Contact, elasticClient, { params, pagination });\n    }),\n  },\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flimit-zero%2Fmongoose-graphql-pagination","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flimit-zero%2Fmongoose-graphql-pagination","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flimit-zero%2Fmongoose-graphql-pagination/lists"}