Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
typeorm-paginator
Advanced tools
Readme
It provides cursor-based pagination and page-based pagination. Even if there is a transformer in the column, it works perfectly.
npm install typeorm-paginator --save
import { CursorPaginator } from 'typeorm-paginator'
Single cursor-based pagination.
const paginator = new CursorPaginator(User, {
orderBy: {
id: false,
},
})
const pagination = await paginator.paginate(repoUsers.createQueryBuilder())
expect(pagination).toEqual({
nodes: [
/*
User { id: 3 },
User { id: 2 },
User { id: 1 },
*/
],
hasPrev: false,
hasNext: false,
nextCursor: expect.any(String),
prevCursor: expect.any(String),
})
Multi cursor-based pagination.
const paginator = new CursorPaginator(User, {
orderBy: [
{ name: true },
{ id: false },
],
})
const result = await paginator.paginate(repoUsers.createQueryBuilder(), { take: 2 })
expect(result).toEqual({
nodes: [
User { id: 3, name: 'a' },
User { id: 5, name: 'b' },
],
hasPrev: false,
hasNext: true,
prevCursor: expect.any(String),
nextCursor: expect.any(String),
})
const resultNext = await paginator.paginate(repoUsers.createQueryBuilder(), { take: 2, nextCursor: result.nextCursor })
expect(resultNext).toEqual({
nodes: [
User { id: 2, name: 'b' },
User { id: 6, name: 'c' },
],
hasPrev: true,
hasNext: true,
prevCursor: expect.any(String),
nextCursor: expect.any(String),
})
const resultNextNext = await paginator.paginate(repoUsers.createQueryBuilder(), { take: 2, nextCursor: resultNext.nextCursor })
expect(resultNextNext).toEqual({
nodes: [
User { id: 4, name: 'c' },
User { id: 1, name: 'c' },
],
hasPrev: true,
hasNext: false,
prevCursor: expect.any(String),
nextCursor: expect.any(String),
})
const resultNextNextPrev = await paginator.paginate(repoUsers.createQueryBuilder(), { take: 2, prevCursor: resultNextNext.prevCursor })
expect(resultNextNextPrev).toEqual({
nodes: [
User { id: 2, name: 'b' },
User { id: 6, name: 'c' },
],
hasPrev: true,
hasNext: true,
prevCursor: expect.any(String),
nextCursor: expect.any(String),
})
import { PagePaginator } from 'typeorm-paginator'
Single cursor-based pagination.
const paginator = new PagePaginator(User, {
orderBy: {
id: false,
},
take: 3,
})
const pagination1 = await paginator.paginate(repoUsers.createQueryBuilder())
expect(pagination1).toEqual({
nodes: [
/*
User { id: 5 },
User { id: 4 },
User { id: 3 },
*/
],
hasNext: true,
})
const pagination1 = await paginator.paginate(repoUsers.createQueryBuilder(), { page: 2 })
expect(pagination1).toEqual({
nodes: [
/*
User { id: 2 },
User { id: 1 },
*/
],
hasNext: false,
})
FAQs
TypeORM query builder pagination library.
The npm package typeorm-paginator receives a total of 11,376 weekly downloads. As such, typeorm-paginator popularity was classified as popular.
We found that typeorm-paginator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.