Skip to main content
Subset is a feature that pre-defines specific field combinations of an Entity to efficiently manage API responses. You can visually define and edit Subsets in the Entity tab of Sonamu UI.
Subsets are not managed in a separate tab. They are managed in the Subsets sheet within the Entity tab. After selecting an Entity, you work in the Subsets sheet alongside Properties, Indexes, Relations, and Enums.

What is a Subset?

A Subset is a predefined field group that selectively retrieves only some fields of an Entity.

Why Use Subsets

Example

Subset Management Screen

Accessing from Entity Tab

To manage Subsets in Sonamu UI:
  1. Click the Entity tab
  2. Select the desired Entity from the left sidebar
  3. Click Subsets among the sheet tabs at the top
Entity Relations Screen

Managing Subsets in the Subsets sheet of Entity tab

Entity Subsets Screen

Screen Layout

The Subsets sheet is organized as follows:
  • Left Sidebar: Entity list (showing currently selected Entity)
  • Top Sheet Tabs: Properties, Indexes, Relations, Enums, Subsets
  • Subset List: All Subsets of the current Entity (A, B, C, etc.)
  • Field Selection Area: Checkboxes for fields to include in the selected Subset

Creating a Subset

1. Navigate to Entity Tab

Click the Entity tab in Sonamu UI.

2. Select Entity

Select the Entity to add a Subset to from the left sidebar.

3. Open Subsets Sheet

Click Subsets among the sheet tabs at the top.

4. Add Subset

Click the [Add Subset] button to create a new Subset.
Subset IDs typically use single alphabet letters (A, B, C…).

5. Select Fields

Select the fields to include in the created Subset: Basic fields:
Relation fields:

Subset Types

Subset A (Basic List)

Purpose: Used for list queries Includes: Required info + summary info
Usage example:

Subset B (Detail View)

Purpose: Single record detail query Includes: All general info (excluding sensitive info)
Usage example:

Subset C (With Relations)

Purpose: Query including related data Includes: Basic info + related Entities
Usage example:

Relation Field Settings

belongsTo Relation

Example: Post β†’ User (author)
When selected, querying Post also fetches author (User) info:

hasMany Relation

Example: User β†’ Post[] (authored posts list)
When selected, querying User also fetches authored Post list:
N+1 problem caution: Including hasMany relations in Subsets may cause additional queries. Only include when necessary.

Editing Subsets

Add/Remove Fields

  1. Navigate to the Entity’s Subsets sheet in the Entity tab
  2. Select the Subset to edit
  3. Click field checkboxes to change inclusion/exclusion
  4. Click [Save] button
Changes applied immediately:

Delete Subset

  1. Navigate to the Entity’s Subsets sheet in the Entity tab
  2. Select the Subset to delete
  3. Click [Delete] button
  4. Click [Confirm] in the confirmation modal
Deleting used Subset: If there are APIs using the Subset you’re deleting, errors may occur.

Practical Examples

User Management System

Blog System

Using in Models

Once Subsets are defined, they can be automatically used in Model APIs.

Using in findMany

Using in findById

Performance Optimization

Select Only Needed Fields

Minimize Relation Loading

Next Steps

Model

Using Subsets in Models

API Development

Using Subsets in APIs