Cursor <Entity, Hint, Fields, Excludes>
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
Parameters
items: Loaded<Entity, Hint, Fields, Excludes>[]
totalCount: number
options: FindByCursorOptions<Entity, Hint, Fields, Excludes>
meta: EntityMetadata<Entity>
Returns Cursor<Entity, Hint, Fields, Excludes>
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
limit
andoffset
, 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
,first
andlast
options while disallowinglimit
andoffset
. ExplicitorderBy
option is required.Use
first
andafter
for forward pagination, orlast
andbefore
for backward pagination.first
andlast
are numbers and serve as an alternative tooffset
, those options are mutually exclusive, use only one at a timebefore
andafter
specify the previous cursor valueThe
Cursor
object provides the following interface: