Cursor <Entity, Hint, Fields, Excludes, IncludeCount>
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
Parameters
items: Loaded<Entity, Hint, Fields, Excludes>[]
totalCount: IncludeCount extends true ? number : undefined
options: FindByCursorOptions<Entity, Hint, Fields, Excludes, IncludeCount>
meta: EntityMetadata<Entity>
Returns Cursor<Entity, Hint, Fields, Excludes, IncludeCount>
Properties
readonlyhasNextPage
readonlyhasPrevPage
readonlyitems
readonlytotalCount
Accessors
endCursor
Returns null | string
length
Returns number
startCursor
Returns null | string
Methods
[iterator]
Returns IterableIterator<Loaded<Entity, Hint, Fields, Excludes>, any, any>
from
Computes the cursor value for a given entity.
Parameters
entity: Entity | Loaded<Entity, Hint, Fields, Excludes>
Returns string
staticdecode
Parameters
value: string
Returns unknown[]
staticencode
Parameters
value: unknown[]
Returns string
staticfor
Computes the cursor value for given entity and order definition.
Parameters
meta: EntityMetadata<Entity>
entity: FilterObject<Entity>
orderBy: OrderDefinition<Entity>
Returns string
staticgetDefinition
Parameters
meta: EntityMetadata<Entity>
orderBy: OrderDefinition<Entity>
Returns [never, QueryOrder][]
As an alternative to the offset-based pagination with
limitandoffset, we can paginate based on a cursor. A cursor is an opaque string that defines a specific place in ordered entity graph. You can useem.findByCursor()to access those options. Under the hood, it will callem.find()andem.count()just like theem.findAndCount()method, but will use the cursor options instead.Supports
before,after,firstandlastoptions while disallowinglimitandoffset. ExplicitorderByoption is required.Use
firstandafterfor forward pagination, orlastandbeforefor backward pagination.firstandlastare numbers and serve as an alternative tooffset, those options are mutually exclusive, use only one at a timebeforeandafterspecify the previous cursor valueThe
Cursorobject provides the following interface: