Skip to main content

Paginating & iterating data

Data pagination

Pagination is a process used to divide a large data set into smaller discrete pages, and this process is also known as paging. Pagination is commonly used by web/mobile applications. For example, when we search for something on Google, it shows the results on pages, and you can move from one page to another by clicking on the page number or next.

Pagination example

In Altogic, data pagination is enabled by Get Multi Objects By Query node. Using this node, you can specify the page number and the page size to paginate model objects. For example, assuming that you have a large dataset, you can paginate through this data using different page numbers and page sizes. If you use a page size of 15, then "Get Multi Objects by Query" node will return a maximum of 15 objects. Depending on your page number, you can get the first 1-15 nodes or the following 16-30. Similarly, if your page size is 10, you can get the objects 1-10, 11-20, or 21-30.

Pagination example with different page sizes
info

Your account plan determines the maximum page size, namely the maximum number of data objects you can fetch from the database using "Get Multi Objects by Query" node. Please review pricing plans for more details.

info

If you paginate to a page that is out of bounds of the select query results, then an empty list is returned, and the notFound output list link point is triggered.

One useful parameter of "Get Multi Objects by Query" node is turning on/off to get the count info summary. If this parameter is turned on, then as a result of the node execution, a countInfo object is also returned as output which provides the total count of objects that matched the select query, total number of pages, current page number, and current page size.

Data iteration

Data iteration is processing the queried data objects one by one until no data object is available for processing. For example, assuming you run a database query and the query resulted in 24 objects, you can iterate over these objects one by one till there is no next object to process.

Iteration example

In Altogic, there are two key nodes used to iterate large data sets one by one.

  • Create Object Iterator - This is the node where you specify your select query expression and sort conditions. As a result of its execution, this node returns an iterator object to iterate its contents one by one.
  • Iterate to Next Object - This node takes a trigger and an iterator as input. You need to connect the iterator you have created using the Create Object Iterator node to this node. The trigger is used to trigger the execution of this node. Basically, this node gets the next available object from the iterator and returns it. If there isn't a next available object, namely, we have reached the end of the queried object list, this node triggers the notFound output link point.
info

There is no limit on the number of objects that can be processed using iteration. During iteration, you are only constrained by the total duration of the service or the total number of nodes executed. However, pagination limits the maximum number of objects that can be returned constrained by the page size parameter. If you will be working on a large data set and taking action per fetched object, it is recommended to use iteration.