Retrieve last x amount of list

0
Hi all, I connected my app to a Rest-api of an IoT device. However, the data consists of a loooooong list of datapoints.  Is it possible to only retrieve - say - 30 records of an entity? In stead of the entire list. Or is it possible to trim the list, based on the amount of objects in the list? Kind regards, Steve Jonk
asked
4 answers
1

If the list contains NPEs then you need to sort them and then iterate over them. Use a counter to stop the iteration once you have processed the desired number of elements, for example

Hope this helps.

answered
0

In the Retrieve action, choose From database, and Select your entity. Add sorting attributes as needed. In the Range, instead of All, choose Custom. Set Limit to 30 and Offset to 0. This gets you the first 30 records on the entity.

answered
0

In a retrieve action, you can set the number of records you want returned.  Select Custom for Range and enter the number of records you would like.

answered
0

Hi Steve, 

that depends on the API: if it allows you to provide a 'max' parameter or something similar, you can specify the amount of results you want.

If not, you'll have to 'trim' the list yourself. this can be done in various ways, depending on what objects you want to keep. To answer your question, yes you can do a 'Count' on the list, after which an exclusive split will allow you to activate different logic based on this count. You could for instance iterate over the list, keep a 'Counter' variable, which fills a list until it reaches 30, after which it deletes the remaining objects, that way effectively trimming your list to an amount you want.

answered