Xano Documentation
Search…
⌃K

External Sorting

How do I use the External query to sort?

First, you must create an Input that is a JSON data type.
The input named external is a JSON data type.
Next, link the configuration in the External query tab to the JSON input using the drop down menu. Additionally, select which permissions you want to grant for external use.
In this example, the external configuration is mapped to the JSON input. Additionally, the 'Allow Sorting Override' is selected as a permission.
Finally, we are ready to use the external query to sort. In order to sort, we must enter in the JSON input in the following format:
{
{
"sort": [
{"sortBy": "","orderBy": ""}
]
}
}
For this example, it would like this in Xano:
In this example, "external" is the input as a JSON data type. This response will sort the data by the 'titles' of the 'book' table in ascending order.
Note for order by: asc = ascending desc = descending

Alternate to JSON input

Front-ends can sometimes have limitations as far as the data you are able to pass as an input. Fortunately, Xano is super-flexible to allow you to workaround these limitations. If you are having issue passing a JSON object as an input in your front-end then you can create the object in the Function Stack as a variable and make it dynamic with scalar inputs.

Step 1

Create the fields sortBy and orderBy as regular text inputs.
Create order by and sort by text inputs.

Step 2

Add a new Function Stack item: Create Variable
Paste the JSON object into the input line and hit import JSON. Or create the object manually using the set filters.
{
{
"sort": [
{"sortBy": "","orderBy": ""}
]
}
}
Then map the sortBy and orderBy paths to their respective inputs.
Map each input to the path they belong to.

Step 3

Reorder your Create Variable function so that is before the Query All Records function. Then navigate to the External tab within the Query All Records and map it to the variable.
Map the variable containing the JSON object and inputs to the by external query section.