QueryOptions (sort, page, limit)
QueryOptions is an object which provides the query meta-data like sort, offset and limit
QueryOptions class contains a builder method for easy "inline" usage.
Properties
limit:number - The maximum records amount to query. default - 0.
offset:number - The amount of record which should be skipped, can also be use for page number. default - 0.
sort:Array - Array of sorted fields and their sort direction - SortItem
1
SortItem{
2
sortOption: SortOptions;// "DESC" | "ASC"
3
field: string;
4
}
Copied!
Usage example
1
public static pagingQuery(query:any,limit:number,page:number){
2
DataModel.findAll(query, QueryOptions.builder()
3
.setLimit(limit)
4
.setOffset(page)
5
.setSortOption(
6
new SortItem(SortOptions.DESC, "amount"),
7
new SortItem(SortOptions.ASC, "lastUpdate")
8
)
9
);
10
}
Copied!
Last modified 3yr ago
Copy link