Paging
Paging request constraints help to traverse large lists of records by splitting them into several parts that are requested separately. This technique is used to reduce the amount of data transferred over the network and to reduce the load on the server. evitaDB supports several ways to paginate query results, which are described in this section.
Page
- argument:int
a mandatory number of page to be returned, positive integer starting from 1
- argument:int
a mandatory size of the page to be returned, positive integer
- requireConstraint:spacing?
- an optional constraint that specifies rules for leaving spaces on certain pages of the query result (see spacing constraint chapter for more details)
- pageNumber
the number of the page returned in the query response
- pageSize
the size of the page returned in the query response
- lastPageNumber
- the last page number available for the query, the request for lastPageNumber + 1 returns the first page
- firstPageItemNumber
the offset of the first record of current page with current page size
- lastPageItemNumber
the offset of the last record of current page with current page size
- first
- TRUE if the current page is the first page available
- last
- TRUE if the current page is the last page available
- hasNext
- TRUE if there is a data for the next page available (i.e. pageNumber + 1 <= lastPageNumber)
- hasPrevious
- TRUE if the current page is the last page available (i.e. pageNumber - 1 > 0)
- empty
- TRUE if the query returned no data at all (i.e. totalRecordCount == 0)
- singlePage
- TRUE if the query returned exactly one page of data (i.e. pageNumber == 1 && lastPageNumber == 1 && totalRecordCount > 0)
- totalRecordCount
the total number of entities available for the query
- data
the list of entities returned in the query response
The result contains the result from the 6th through the 10th record of the query result. It returns only a primary key of the records because no content request was specified, and it is sorted by the primary key in ascending order because no order was specified in the query.
Strip
- argument:int
a mandatory offset of the first record of the page to be returned, positive integer starting from 0
- argument:int
a mandatory limit of the records to be returned, positive integer
- offset
the offset of the first record returned in the query response
- limit
the limit of the records returned in the query response
- first
- TRUE if the current strip starts with the first records of the query result
- last
- TRUE if the current strip ends with the last records of the query result
- hasNext
- TRUE if there is a data for the next next available (i.e. last == false)
- hasPrevious
- TRUE if the current page is the last page available (i.e. first == false)
- empty
- TRUE if the query returned no data at all (i.e. totalRecordCount == 0)
- totalRecordCount
the total number of entities available for the query
- data
the list of entities returned in the query response
The result contains the result from the 76th through the 95th record of the query result. It returns only a primary key of the records because no content request was specified, and it is sorted by the primary key in ascending order because no order was specified in the query.
Spacing
- requireConstraint:gap+
one or more constraints that specify rules for leaving spaces on certain pages of the query result
Spacing constraints are useful when you need to make room for additional content on certain pages of the query result, such as advertisements, banners, blog posts, or other external content that you want to display between records. For example, let's say you want to display an ad on every even page up to the 10th page, and you also want to display a blog post on the 1st and 4th page. To accomplish this, you would use the following query:
The first page contains 9 records (one slot left for the blog post), the second page contains 9 records (one slot left for the advertisement, because the page number is even), and the fourth page contains only 8 records (one slot left for the blog post and one slot left for the advertisement, because the page number is even), the last page number is recalculated because a total of 7 records were left on the front pages.
Gap
- argument:int
a mandatory number specifying the size of the gap to leave empty on the page (i.e., the number of records to skip on the page)
- argument:expression
- a mandatory expression that must be evaluated to a boolean value, indicating whether the gap should be applied to the given page or not.
- variableName: pageNumber of type: int
the number of the page to be evaluated