Skip to main content
Version: 3.4.0

PaginatedCollection

Defined in: src/lib/models/paginated-collection.ts:5

Type Parameters

T

T extends IPaginatedObject

Constructors

Constructor

new PaginatedCollection<T>(data, page, from?, to?, total?, perPage?, prevPageUrl?, nextPageUrl?, lastPage?, firstPageUrl?, lastPageUrl?): PaginatedCollection<T>

Defined in: src/lib/models/paginated-collection.ts:6

Parameters

data

T[]

page

number

from?

number

to?

number

total?

number

perPage?

number

prevPageUrl?

string

nextPageUrl?

string

lastPage?

number

firstPageUrl?

string

lastPageUrl?

string

Returns

PaginatedCollection<T>

Properties

data

data: T[]

Defined in: src/lib/models/paginated-collection.ts:7


firstPageUrl?

readonly optional firstPageUrl?: string

Defined in: src/lib/models/paginated-collection.ts:16


from?

readonly optional from?: number

Defined in: src/lib/models/paginated-collection.ts:9


lastPage?

readonly optional lastPage?: number

Defined in: src/lib/models/paginated-collection.ts:15


lastPageUrl?

readonly optional lastPageUrl?: string

Defined in: src/lib/models/paginated-collection.ts:17


nextPageUrl?

readonly optional nextPageUrl?: string

Defined in: src/lib/models/paginated-collection.ts:14


page

readonly page: number

Defined in: src/lib/models/paginated-collection.ts:8


perPage?

readonly optional perPage?: number

Defined in: src/lib/models/paginated-collection.ts:12


prevPageUrl?

readonly optional prevPageUrl?: string

Defined in: src/lib/models/paginated-collection.ts:13


to?

readonly optional to?: number

Defined in: src/lib/models/paginated-collection.ts:10


total?

readonly optional total?: number

Defined in: src/lib/models/paginated-collection.ts:11

Methods

normalize()

normalize(id?): INormalized

Defined in: src/lib/models/paginated-collection.ts:35

Normalize the collection to a paginated list of ids for state-managed applications.

This method returns a single key object, where the key is the page number and the associated value is an array of ids. Each id is fetched by the collection items, looking up for the "id" key. If an id is supplied to this method, it will be used instead of the default "id" key.

Please note that in case the key doesn't exist in the collection's item, a KeyNotFoundError is thrown

Parameters

id?

string

Returns

INormalized

[]

Throws

KeyNotFoundItem