$ open source · GPL-3.0 — need a commercial license? imqueue.com →

DataPage interface

One page of results together with the size of the whole set.

Signature:

export interface DataPage<T> 

Remarks

The envelope a paginated service method returns, so a caller that asked for 20 rows can still render "20 of 1,340" without a second round trip. Nothing in this package produces one — it is a shape for your own service methods to declare and fill, which is why data is whatever you put in it rather than an array.

Example

@expose()
public async listReservations(
    page?: PaginationInput,
): Promise<DataPage<Reservation[]>> {
    const { rows, count } = await Reservation.findAndCountAll(
        query.toLimitOptions(page),
    );

    return { total: count, data: rows };
}

Properties

Property

Modifiers

Type

Description

data

T

The page itself.

total

number

Rows matching the query in total, ignoring the page window.