Installations
npm install typeorm-paginator
Releases
Unable to fetch releases
Developer
wan2land
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
Yes
Node Version
14.17.5
NPM Version
7.21.0
Statistics
3 Stars
145 Commits
1 Forks
2 Watching
8 Branches
3 Contributors
Updated on 11 Feb 2022
Languages
TypeScript (99.3%)
JavaScript (0.7%)
Total Downloads
Cumulative downloads
Total Downloads
370,091
Last day
45%
2,895
Compared to previous day
Last week
1.4%
7,300
Compared to previous week
Last month
16.5%
32,099
Compared to previous month
Last year
1,041.2%
326,324
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
TypeORM Paginator
It provides cursor-based pagination and page-based pagination. Even if there is a transformer in the column, it works perfectly.
Installation
1npm install typeorm-paginator --save
Usage
Cursor-based Pagination
1import { CursorPaginator } from 'typeorm-paginator'
Single cursor-based pagination.
1const paginator = new CursorPaginator(User, { 2 orderBy: { 3 id: false, 4 }, 5}) 6 7const pagination = await paginator.paginate(repoUsers.createQueryBuilder()) 8 9expect(pagination).toEqual({ 10 nodes: [ 11 /* 12 User { id: 3 }, 13 User { id: 2 }, 14 User { id: 1 }, 15 */ 16 ], 17 hasPrev: false, 18 hasNext: false, 19 nextCursor: expect.any(String), 20 prevCursor: expect.any(String), 21})
Multi cursor-based pagination.
1const paginator = new CursorPaginator(User, { 2 orderBy: [ 3 { name: true }, 4 { id: false }, 5 ], 6}) 7 8const result = await paginator.paginate(repoUsers.createQueryBuilder(), { take: 2 }) 9expect(result).toEqual({ 10 nodes: [ 11 User { id: 3, name: 'a' }, 12 User { id: 5, name: 'b' }, 13 ], 14 hasPrev: false, 15 hasNext: true, 16 prevCursor: expect.any(String), 17 nextCursor: expect.any(String), 18}) 19 20const resultNext = await paginator.paginate(repoUsers.createQueryBuilder(), { take: 2, nextCursor: result.nextCursor }) 21expect(resultNext).toEqual({ 22 nodes: [ 23 User { id: 2, name: 'b' }, 24 User { id: 6, name: 'c' }, 25 ], 26 hasPrev: true, 27 hasNext: true, 28 prevCursor: expect.any(String), 29 nextCursor: expect.any(String), 30}) 31 32const resultNextNext = await paginator.paginate(repoUsers.createQueryBuilder(), { take: 2, nextCursor: resultNext.nextCursor }) 33expect(resultNextNext).toEqual({ 34 nodes: [ 35 User { id: 4, name: 'c' }, 36 User { id: 1, name: 'c' }, 37 ], 38 hasPrev: true, 39 hasNext: false, 40 prevCursor: expect.any(String), 41 nextCursor: expect.any(String), 42}) 43 44const resultNextNextPrev = await paginator.paginate(repoUsers.createQueryBuilder(), { take: 2, prevCursor: resultNextNext.prevCursor }) 45expect(resultNextNextPrev).toEqual({ 46 nodes: [ 47 User { id: 2, name: 'b' }, 48 User { id: 6, name: 'c' }, 49 ], 50 hasPrev: true, 51 hasNext: true, 52 prevCursor: expect.any(String), 53 nextCursor: expect.any(String), 54})
Page-based Pagination
1import { PagePaginator } from 'typeorm-paginator'
Single cursor-based pagination.
1const paginator = new PagePaginator(User, { 2 orderBy: { 3 id: false, 4 }, 5 take: 3, 6}) 7 8const pagination1 = await paginator.paginate(repoUsers.createQueryBuilder()) 9 10expect(pagination1).toEqual({ 11 nodes: [ 12 /* 13 User { id: 5 }, 14 User { id: 4 }, 15 User { id: 3 }, 16 */ 17 ], 18 hasNext: true, 19}) 20 21const pagination1 = await paginator.paginate(repoUsers.createQueryBuilder(), { page: 2 }) 22 23expect(pagination1).toEqual({ 24 nodes: [ 25 /* 26 User { id: 2 }, 27 User { id: 1 }, 28 */ 29 ], 30 hasNext: false, 31})
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/wan2land/typeorm-paginator/nodejs.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/wan2land/typeorm-paginator/nodejs.yml/main?enable=pin
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 1 out of 1 npmCommand dependencies pinned
Reason
Found 1/29 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/nodejs.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
license file not detected
Details
- Warn: project does not have a license file
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
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 30 are checked with a SAST tool
Reason
24 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-jqv5-7xpx-qj74
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-fx4w-v43j-vc45
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-776f-qx25-q3cc
Score
2.4
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More