Skip to main content
Subsets are predefined query templates for retrieving Entity data in various forms.

Subset Overview

Flexible Retrieval

Data formats for each situation A, P, SS, etc.

Type Safety

Compile-time validation Automatic type inference

Relation Loading

Integrated JOIN and Loader 1:N, N:M support

Performance Optimization

Select only needed fields Solve N+1 problem

Why Subsets are Needed

Problem: Limitations of Single Queries

Each API requires different data formats:

Solution: Unify with Subsets

Subset Components

1. SubsetQuery - Base Query

Field selection defined in Entity:

2. LoaderQuery - Relation Loading

Loading 1:N, N:M relation data:

3. Hydrate - Result Transformation

Flat data → Nested object:

Subset Naming Conventions

Common Subset name patterns:
Subset names can be freely defined. Use consistent conventions within your team.

Practical Examples

User List API

User Profile API

Subset vs Raw Puri

Using Raw Puri

When to use Raw Puri?
  • Complex queries not expressible with Subsets
  • Special cases requiring performance optimization
  • One-time data migrations
For typical CRUD, always use Subsets.

Next Steps

Defining Subsets

Create Subsets in Entity

Using Subsets

Use Subsets in Model

Nested Relations

Load 1:N, N:M with LoaderQuery

Puri Basics

Learn Puri query builder