Skip to main content

Overview

PaginatedResult wraps query results with pagination metadata. It provides a consistent structure for paginated data and handles deep serialization of entities and value objects.

Creating PaginatedResult

From Repository

Most commonly, you’ll get PaginatedResult from repository methods:

Manual Creation

Create a PaginatedResult directly:

From Array (Testing/In-Memory)

Apply criteria to an in-memory array:
fromArray() is useful for testing or when working with small datasets. For large datasets, always use database-level filtering.

Pagination Metadata

PaginationMeta Structure

Accessing Metadata

Creating Metadata Manually

Utility Properties

isEmpty

Check if result has no data:

hasMore

Check if there are more pages:

Transforming Results

map()

Transform each item in the result:

Chaining map()

Serialization

toJSON()

Deep serialize all entities, value objects, and IDs:

What Gets Serialized

Type Safety

The return type reflects serialization:

API Response Pattern

Pagination UI Example

Complete Example

fromArray() Behavior

When using fromArray(), the criteria is fully applied in memory:
fromArray() loads all data into memory before filtering. Only use it for small datasets or testing. For production, implement filtering at the database level.

API Reference

Static Methods

Instance Properties

Instance Methods