Comments (1)
I'm experimenting with this code snippet, it would have to query the count but still get the hasPreviousPage
and hasNextPage
info:
const startCursor = edges.length > 0 ? edges[0].cursor : null;
const endCursor = edges.length > 0 ? edges[edges.length - 1].cursor : null;
const prevPaginationQuery = startCursor ? getPaginationQuery(reverseOrder(order), parseCursor(startCursor)) : null;
const prevPaginationWhere = prevPaginationQuery ? { [Op.and]: [prevPaginationQuery, where] } : where;
const prevInstance = startCursor && (await modelClass.findOne({ where: prevPaginationWhere, ...restQueryOptions }));
const nextPaginationQuery = endCursor ? getPaginationQuery(order, parseCursor(endCursor)) : null;
const nextPaginationWhere = nextPaginationQuery ? { [Op.and]: [nextPaginationQuery, where] } : where;
const nextInstance = endCursor && (await modelClass.findOne({ where: nextPaginationWhere, ...restQueryOptions }));
const pageInfo = {
startCursor,
endCursor,
hasPreviousPage: !!prevInstance,
hasNextPage: !!nextInstance,
};
from sequelize-cursor-pagination.
Related Issues (20)
- Can't handle one-to-many HOT 1
- On sequelize model option Paranoid: true, cursor generating different query. HOT 1
- totalCount? HOT 1
- Add UUID support HOT 1
- multiple order generates invalid query HOT 2
- Add support for HAVING clause HOT 1
- Add support for GROUP BY clause HOT 1
- UUID PK and order generates unwanted results HOT 1
- ` after: pagination.cursors.after` in the option always throw error "pagination was use before it was defined" HOT 1
- Incorrect comparison of primary key breaks pagination of common values
- composite primary keys HOT 2
- Option to override ordering parameters HOT 4
- Support ordering on associated models HOT 2
- Pagination of relations? HOT 7
- Module '"sequelize"' has no exported member 'Attributes'. HOT 1
- Support ordering with DESC / ASC NULL FIRST HOT 1
- Using "group" option HOT 13
- Support custom model method name other than 'paginate' HOT 1
- nodejs.SequelizeDatabaseError: Undeclared variable: NaN
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sequelize-cursor-pagination.