Describes a request to fetch only subset of records.
First and subsequent requests to single service can be distinguished. First time caller can specify only "pageSize" to indicates how many records should be returned. All other attributes are left blank.
Subsequent request can be more specific based on what is REST service capable of and how the service responded via PaginationCursor. For example if service returned "total" amount of records then subsequest requests can specify "offset" and "pageSize" within the range.
- Version:
- 17.1.1
- Source:
- See:
-
- PaginationCursor which holds an information coming from previous Operation.perform() call.
- Abcs.Operations().read(..) to use
PaginationRequest
from Application Builder custom code.
Methods
(static) createStandard(params) → {operation/js/api/PaginationRequest}
stable API
Creates an instance of PaginationRequest
.
You can pass an instance of PaginationRequest
into Abcs.Operations().read(..) method to fetch just
particular page of records from Application Builder custom code.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
Object | Object literal with all possible parameters. Properties
|
- Version:
- 17.1.1
- Source:
Returns:
Examples
Creates an PaginationRequest
instance which fetch first 30 records.
PaginationRequest.createStandard({
pageSize: 30
});
Creates an PaginationRequest
instance which fetch second 15 records.
PaginationRequest.createStandard({
offset: 15,
pageSize: 15
});
Creates an PaginationRequest
instance which fetch first 15 records and also returns total count of available records.
PaginationRequest.createStandard({
pageSize: 15,
totalResult: true
});
Creates an PaginationRequest
instance which fetch first 15 records and subsequently fetches second page of records using PaginationCursor.
require([
'operation/js/api/PaginationRequest'
], function(PaginationRequest) {
var employee = Abcs.Entities().findById('my.custom.bop.Employee');
var firstPageRequest = PaginationRequest.createStandard({
pageSize: 15
});
var operation = Abcs.Operations().read({
entity: employee,
pagination: firstPageRequest
});
operation.perform().then(function(operationResult) {
if (operationResult.isSuccess()) {
// Process data from the first page any way you need
var paginationCursor = operationResult.getPaginationCursor();
var secondPageRequest = PaginationRequest.createStandard({
pageSize: 15,
cursor: paginationCursor
});
Abcs.Operations().read({
entity: employee,
pagination: secondPageRequest
}).perform().then(function(secondResult) {
// Process data from the second page any way you need
});
}
});
});
getOffset() → {Integer}
stable API
Gets the offset defined for this PaginationRequest
.
Offset is numbered from 0. For example when "offset" is set to 5 and "pageSize" to 10, it means client is requesting 10 records starting from 6th item (inclusive).
- Version:
- 17.1.1
- Source:
Returns:
- Type
- Integer
getPageSize() → {Integer}
stable API
Gets page size (= number of records requested to be fetched) defined for this PaginationRequest
.
- Version:
- 17.1.1
- Source:
Returns:
- Type
- Integer
getPaginationCursor() → {operation/js/api/PaginationCursor}
stable API
Gets PaginationCursor defined for this PaginationRequest
.
Use PaginationCursor if your Operation implementation requires information returned from previous REST call, to build and perform subsequent REST call.
- Version:
- 17.1.1
- Source:
Returns:
isTotalResults() → {Boolean}
stable API
Gets the flag of whether client asks for total results available.
Use wisely even if your service supports this as counting total number of records is in general more costly for a backend to calculate.
- Version:
- 17.1.1
- Source:
Returns:
- Type
- Boolean