{"_id":"drizzle-pagination","_rev":"11-b0cfb54e93e13f928136c7a17aa3c250","name":"drizzle-pagination","dist-tags":{"latest":"1.0.12"},"versions":{"1.0.8":{"name":"drizzle-pagination","version":"1.0.8","keywords":["drizzle","orm","pagination","drizzle-orm","cursor pagination","drizzle pagination","paginate drizzle"],"author":{"name":"Michael Tromba"},"license":"MIT","_id":"drizzle-pagination@1.0.8","maintainers":[{"name":"miketromba","email":"mike.tromba@gmail.com"}],"homepage":"https://github.com/miketromba/drizzle-pagination#readme","bugs":{"url":"https://github.com/miketromba/drizzle-pagination/issues"},"dist":{"shasum":"36841f7c877e133f55d3daebe0ad6a14c49a16fd","tarball":"https://registry.npmjs.org/drizzle-pagination/-/drizzle-pagination-1.0.8.tgz","fileCount":8,"integrity":"sha512-OsMbf8kGcY7V2PksKbOcOeby6q+8cRzSH7b6cRVacVfZY4qA8yzoYiRg1EheGv/semp+zkDaXjubWKSPAJGu6w==","signatures":[{"sig":"MEQCIC4Z+m/Gbf0TuvPb7nmrkDJIgi0ceqZDolwcVfYKss1YAiBfUDqxmAcQ7jUYNvHQBqK9wGXCHTd29lJwHNjpOdJk4Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16963},"main":"./dist/index.js","_from":"file:drizzle-pagination-1.0.8.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"build":"tsup src/index.ts --format cjs,esm --dts --clean","clean":"rimraf dist/","pretest":"pnpm build","prebuild":"pnpm clean","prepublish":"pnpm build"},"_npmUser":{"name":"miketromba","email":"mike.tromba@gmail.com"},"_resolved":"","_integrity":"","repository":{"url":"git+https://github.com/miketromba/drizzle-pagination.git","type":"git"},"_npmVersion":"6.14.8","description":"Easily add cursor pagination to your Drizzle ORM queries.","directories":{},"_nodeVersion":"18.13.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^7.1.0","rimraf":"^5.0.1","typescript":"^5.1.3"},"peerDependencies":{"drizzle-orm":"^0.27.2"},"_npmOperationalInternal":{"tmp":"tmp/drizzle-pagination_1.0.8_1692891380034_0.3091884130417293","host":"s3://npm-registry-packages"}},"1.0.10":{"name":"drizzle-pagination","version":"1.0.10","keywords":["drizzle","orm","pagination","drizzle-orm","cursor pagination","drizzle pagination","paginate drizzle"],"author":{"name":"Michael Tromba"},"license":"MIT","_id":"drizzle-pagination@1.0.10","maintainers":[{"name":"miketromba","email":"mike.tromba@gmail.com"}],"homepage":"https://github.com/miketromba/drizzle-pagination#readme","bugs":{"url":"https://github.com/miketromba/drizzle-pagination/issues"},"dist":{"shasum":"e4fe2539dde5a7ebc79ee44b925ca52879a96492","tarball":"https://registry.npmjs.org/drizzle-pagination/-/drizzle-pagination-1.0.10.tgz","fileCount":8,"integrity":"sha512-4n811FkmQukhDs9y91sK5nRNPnK1cH+soLmw84rwpJHPJjkFr6zD/f8+UHRv9mldoA/mq1JihMpE3/Lz6h6INA==","signatures":[{"sig":"MEYCIQDKOtBmx8n9LTwJJt+rf48D9kE08lBByp1Sw/0ZmHXougIhAJ+DHaN8O8xBRWWF1dVMtd+k6Ngn6NcaTYS83ojG6jhK","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16894},"main":"./dist/index.js","_from":"file:drizzle-pagination-1.0.10.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"build":"tsup src/index.ts --format cjs,esm --dts --clean","clean":"rimraf dist/","pretest":"pnpm build","prebuild":"pnpm clean","prepublish":"pnpm build"},"_npmUser":{"name":"miketromba","email":"mike.tromba@gmail.com"},"_resolved":"","_integrity":"","repository":{"url":"git+https://github.com/miketromba/drizzle-pagination.git","type":"git"},"_npmVersion":"6.14.8","description":"Easily add cursor pagination to your Drizzle ORM queries.","directories":{},"_nodeVersion":"18.13.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^7.1.0","rimraf":"^5.0.1","typescript":"^5.1.3"},"peerDependencies":{"drizzle-orm":">=0.27.2 <1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/drizzle-pagination_1.0.10_1697578807686_0.2827384351056661","host":"s3://npm-registry-packages"}},"1.0.11":{"name":"drizzle-pagination","version":"1.0.11","keywords":["drizzle","orm","pagination","drizzle-orm","cursor pagination","drizzle pagination","paginate drizzle"],"author":{"name":"Michael Tromba"},"license":"MIT","_id":"drizzle-pagination@1.0.11","maintainers":[{"name":"miketromba","email":"mike.tromba@gmail.com"}],"homepage":"https://github.com/miketromba/drizzle-pagination#readme","bugs":{"url":"https://github.com/miketromba/drizzle-pagination/issues"},"dist":{"shasum":"d4cb40d375fb9a0b8ff954856daa3ea9743c2d82","tarball":"https://registry.npmjs.org/drizzle-pagination/-/drizzle-pagination-1.0.11.tgz","fileCount":3,"integrity":"sha512-5TX8KfRgRrto8+T/3eMliRtRoJoJaSLyeW3ePszWLbkaIuOLJ86gaUopbbzb/Ls+WB/bRp0/7ezcT1rC0ea+kg==","signatures":[{"sig":"MEUCIA0H1UQ6GyX7oqo41P6u3ZfpCwTW3i8fPpTfBgRdrElKAiEA3niixarrVqeI+C9sb0MY3uEUnea0fnlbqs1OzHsrWAU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5960},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"e49eb60030f2ca0241035360fe51bf1d19929316","scripts":{"build":"tsup src/index.ts --format cjs,esm --dts --clean","clean":"rimraf dist/","pretest":"pnpm build","prebuild":"pnpm clean","prepublish":"pnpm build"},"_npmUser":{"name":"miketromba","email":"mike.tromba@gmail.com"},"repository":{"url":"git+https://github.com/miketromba/drizzle-pagination.git","type":"git"},"_npmVersion":"10.2.3","description":"Easily add cursor pagination to your Drizzle ORM queries.","directories":{},"_nodeVersion":"20.10.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^7.1.0","rimraf":"^5.0.1","typescript":"^5.1.3"},"peerDependencies":{"drizzle-orm":">=0.27.2 <1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/drizzle-pagination_1.0.11_1727808850136_0.08458055513573881","host":"s3://npm-registry-packages"}},"1.0.12":{"name":"drizzle-pagination","version":"1.0.12","description":"Easily add cursor pagination to your Drizzle ORM queries.","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/miketromba/drizzle-pagination.git"},"exports":{".":{"require":"./dist/index.js","import":"./dist/index.mjs","types":"./dist/index.d.ts"}},"scripts":{"clean":"rimraf dist/","prebuild":"pnpm clean","build":"tsup src/index.ts --format cjs,esm --dts --clean","pretest":"pnpm build","prepublish":"pnpm build"},"keywords":["drizzle","orm","pagination","drizzle-orm","cursor pagination","drizzle pagination","paginate drizzle"],"author":{"name":"Michael Tromba"},"license":"MIT","peerDependencies":{"drizzle-orm":">=0.27.2 <1.0.0"},"devDependencies":{"rimraf":"^5.0.1","tsup":"^7.1.0","typescript":"^5.1.3"},"_id":"drizzle-pagination@1.0.12","gitHead":"e49eb60030f2ca0241035360fe51bf1d19929316","bugs":{"url":"https://github.com/miketromba/drizzle-pagination/issues"},"homepage":"https://github.com/miketromba/drizzle-pagination#readme","_nodeVersion":"20.10.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-t+SW+FNUhsx8jGuSwtEvcUrDhwYYQpcp0eCyMVl1F/z0LJ2E/yNZekUO6UeGMRGi0GQAYjn/YxHFbrLh9+3zGg==","shasum":"447a1e25e7281f8b26f329113b829e58bba0962f","tarball":"https://registry.npmjs.org/drizzle-pagination/-/drizzle-pagination-1.0.12.tgz","fileCount":7,"unpackedSize":13582,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIElg6CnrYpRnClyKpM8wmMh7kEP4JAU2l13mxrM8eo5lAiBZ1l8TbMWmI+1XoSYqaewZ0yktAoeR+/ln90M7ZXd+cQ=="}]},"_npmUser":{"name":"miketromba","email":"mike.tromba@gmail.com"},"directories":{},"maintainers":[{"name":"miketromba","email":"mike.tromba@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/drizzle-pagination_1.0.12_1731139841923_0.7597506822547935"},"_hasShrinkwrap":false}},"time":{"created":"2023-08-24T15:36:20.033Z","modified":"2024-11-09T08:10:42.307Z","1.0.0":"2023-07-14T16:57:31.260Z","1.0.1":"2023-07-14T16:59:42.432Z","1.0.2":"2023-07-14T17:51:37.584Z","1.0.3":"2023-07-14T17:52:41.097Z","1.0.4":"2023-07-14T17:55:43.067Z","1.0.6":"2023-07-14T18:05:54.277Z","1.0.7":"2023-07-14T18:14:48.562Z","1.0.8":"2023-08-24T15:36:20.272Z","1.0.10":"2023-10-17T21:40:07.921Z","1.0.11":"2024-10-01T18:54:10.311Z","1.0.12":"2024-11-09T08:10:42.115Z"},"bugs":{"url":"https://github.com/miketromba/drizzle-pagination/issues"},"author":{"name":"Michael Tromba"},"license":"MIT","homepage":"https://github.com/miketromba/drizzle-pagination#readme","keywords":["drizzle","orm","pagination","drizzle-orm","cursor pagination","drizzle pagination","paginate drizzle"],"repository":{"type":"git","url":"git+https://github.com/miketromba/drizzle-pagination.git"},"description":"Easily add cursor pagination to your Drizzle ORM queries.","maintainers":[{"name":"miketromba","email":"mike.tromba@gmail.com"}],"readme":"### 👉 _Job hunting?_ I'm building an AI that helps you get hired: [ApplyFox.ai](https://applyfox.ai)\n\n[<img width=\"829\" alt=\"applyfox-829x90\" src=\"https://github.com/user-attachments/assets/6b45becd-5e8a-42db-8cf5-252af04ed8d9\">](https://applyfox.ai)\n\n---\n\n# drizzle-pagination\nEasily add cursor pagination to your drizzle-orm queries.\n\n## Installation\n```bash\nnpm install drizzle-pagination\n```\n\n## Usage\n\n### With a single, unique cursor\nUse a single cursor when the column that you want to sort your results by is guaranteed to be unique (for example, an `id` column).\n```js\nimport { eq } from 'drizzle-orm'\nimport { withCursorPagination } from 'drizzle-pagination'\n\nconst page = await db.query.post.findMany(\n    withCursorPagination({\n        where: eq(schema.post.status, 'published'), // 'where' is optional\n        limit: 32,\n        cursors: [\n            [\n                schema.post.id, // Column to use for cursor \n                'asc', // Sort order ('asc' or 'desc')\n                '94b5a795-5af4-40c3-8db8-a1c33906f5af' // Cursor value\n            ]\n        ]\n    })\n)\n```\n> **Warning** - \n> When using a single cursor, make sure it is a unique column - otherwise you may get unexpected results.\n\n### With two cursors (one non-unique sequential cursor, with a unique cursor as a fallback)\nUse two cursors when you want to order your results by a column that is not unique. For example:\n```js\nconst page = await db.query.post.findMany(\n    withCursorPagination({\n        where: eq(schema.post.status, 'published'),\n        limit: 32,\n        cursors: [\n            // Non-unique, sequential column\n            [schema.post.publishedAt, 'desc', '2023-07-14 16:00:00'],\n            // Unique column as a fallback so you get a stable sort order\n            [schema.post.id, 'asc', '94b5a795-5af4-40c3-8db8-a1c33906f5af']\n        ]\n    })\n)\n```\n> **Warning** - \n> When using two cursors, your second cursor should always be a unique column to ensure a stable sort order.\n\n### Using spread syntax\nUse spread syntax to combine the `withCursorPagination` helper with other query inputs, like the `with` option, for example. \n```js\nconst page = await db.query.post.findMany({\n    ...withCursorPagination({\n        where: eq(schema.post.status, 'published'),\n        limit: 32,\n        cursors: [\n            [schema.post.publishedAt, 'desc', '2023-07-14 16:00:00'],\n            [schema.post.id, 'asc', '94b5a795-5af4-40c3-8db8-a1c33906f5af']\n        ]\n    }),\n    with: { author: true }\n})\n```\n> **Warning** - \n> When using spread syntax, make sure to let `withCursorPagination` control the `orderBy` and `where` options, otherwise you will break the pagination.\n\n### What about nullable columns?\nPaginating with a nullable column may have varied results depending on the database/driver you're using. If possible, try to use non-nullable columns for your pagination. For example:\n\n#### Instead of a nullable `string` column:\nSet the default value to an empty string. All columns with the empty string will appear at the top of an ascending sort. \n\n#### Instead of a nullable `datetime` column:\n\nSet the default value to \"1970-01-01 00:00:00\". Then, in your application, instead of doing a null check, check for the default value.\n\n```js\nconst date = someDate === \"1970-01-01 00:00:00\" ? null : someDate\n```\n\nThis will ensure that the order of your results will always be what you expect.\n\n### Can I use more than two cursors?\n**Not yet.** Right now this library only supports using one or two cursors. This should cover the majority of use cases. That being said, a PR adding support for a dynamic amount of cursors is welcome. E.g. A common use-case for 3+ cursors might be: `[firstName, lastName, id]`.\n\n## Contributing\nPRs are welcome!\n\n## License\nThis package is distributed under the [MIT license](https://opensource.org/license/mit/).\n","readmeFilename":"Readme.md"}