Pagination
Overview
ElastiCORE supports pagination in various ways through Entity and DTO definitions.
Automatic Pagination Configuration
Configuration via Entity
When the @expose(n) or @service(n) annotation is specified on an Entity, pagination is automatically applied:
entity:
Article:
meta: entity @expose(50) # 50 items per page
fields:
aid: string @id @genid
title: string(200)! @search(like)
Configuration via DTO
When the @searchable(...) annotation is specified on a DTO, pagination fields are auto-generated:
dto:
ArticleSearchDTO:
meta: dto @searchable(entity=Article, pageSize=50)
fields:
title: string @search(like)
Auto-generated Pagination Fields
The following fields are automatically generated in SearchDTOs:
pageNumber: Page number (default: 0)pageSize/sizeVal: Page sizesortCode: Sort field name
Pagination in DBMS Port
When the return type in a DBMS Port is Page<DTO>, pagination is automatically handled:
port:
ProductDbPortService:
meta: dbms @datasource("product")
methods:
getProductList:
meta: method -- Product list (paginated)
params:
input: ProductSearchDTO
return: Page<ProductDTO>
pageable: true
nativeQuery: true
query: |
SELECT p.id, p.name, p.price, p.category
FROM products p
WHERE p.active = true
Sort Processing
Automatic sorting is applied through the sortCode parameter:
# Request example
{"sortCode": "name+,age-"}
# Generated SQL
ORDER BY name ASC, age DESC
+: Ascending (ASC)-: Descending (DESC)