@tusss/ood
    Preparing search index...

    Class Pagination

    Helper class for calculating pagination offsets and limits.

    Basic pagination usage

    const pagination = new Pagination({ page: 2, perPage: 10 });
    console.log(pagination.skip); // 10
    console.log(pagination.limit); // 10

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    Accessors

    Methods

    Constructors

    Properties

    page: number

    The 1-based index of the current page.

    perPage: number

    The maximum number of items to return per page.

    page: number = 1

    Default page index (1).

    perPage: number = 10

    Default page size (10).

    Accessors

    • get limit(): number

      The maximum number of items to return (alias for perPage).

      Returns number

    • get skip(): number

      The number of items to skip/offset for database or API queries.

      Returns number

    Methods

    • Implements the JSON.stringify() behavior.

      It uses toStruct to get the plain object structure under the hood.

      It is encouraged to use toStruct instead of this method because it provides better clarity and expressiveness about the data structure being serialized. This method is provided only to support the JSON.stringify() serialization.

      Returns ClassProperties<TData>

      A plain object structure containing the model's serializable properties.

    • Converts the model instance into a plain data structure (struct).

      This method extracts the model's property data, removing functions, methods, or class-specific instance details, returning a clean structural representation.

      Returns ClassProperties<Pagination>

      A plain object structure containing the model's serializable properties.