Stream ?

Options
Michael Udinski
Michael Udinski Administrator

ADMIN

edited October 2022 in ? Video Tutorials


Stream is a new return type of Query All Records that is used exclusively with For Each Loops. Stream retrieves database records in a memory-friendly way to be used in your For Each Loop. This new feature is especially useful when using large datasets that would normally require recursive function stacks.

Comments

  • pachocastillosr
    pachocastillosr Member
    edited September 2023
    Options

    @Michael Udinski this is a great feature!

    I am processing large lists of data using "for each loop" but data is obtained mainly via external apis.

    Is there a way to apply "stream" to other lists of objects (that are not obtained via "Query All Records") to avoid timeouts?

    Example: I'm getting 1000 json objects from an external api and want to modify them in Xano using "For each loop" and then post all the transformed json objects to another external api.

    What I've done in cases like this is getting the 1000 json objects in a custom function that calls the external api multiple times getting 100 objects per call (using paging) and generates an array with all the retrieved objects.

    This new array of 1000 objects (which is the response of the custom function), is now used as input in "For each loop", where I run transformations to the data of each object.

    Is this a good practice? Would it still be a good practice if they where 10,000 objects instead of 1000?

    I'd appreciate any insights. Thanks!