File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -91,8 +91,22 @@ export default class Paginator<Entity extends ObjectLiteral> {
9191 public async paginate (
9292 builder : SelectQueryBuilder < Entity > ,
9393 ) : Promise < PagingResult < Entity > > {
94- const entities = await this . appendPagingQuery ( builder ) . getMany ( ) ;
95- const hasMore = entities . length > this . limit ;
94+ let entities = await this . appendPagingQuery ( builder ) . getMany ( ) ;
95+ let hasMore = entities . length > this . limit ;
96+
97+ if (
98+ this . hasBeforeCursor ( ) &&
99+ ! this . hasAfterCursor ( ) &&
100+ entities . length < this . limit
101+ ) {
102+ this . afterCursor = null ;
103+ this . beforeCursor = null ;
104+ this . nextAfterCursor = null ;
105+ this . nextBeforeCursor = null ;
106+
107+ entities = await this . appendPagingQuery ( builder ) . getMany ( ) ;
108+ hasMore = entities . length > this . limit ;
109+ }
96110
97111 if ( hasMore ) {
98112 entities . splice ( entities . length - 1 , 1 ) ;
You can’t perform that action at this time.
0 commit comments