The below example details how to create an Addon from the Query all Records function. Additionally, it shows how to use an Addon to return a list of items.
The example is for a GET API endpoint that is returning all the records from the merchant table. The Addon will extend the response with the deal table, showing a list of all deals associated with the merchant record.
Creating an Addon and returning a list of items:
Within, the Function Stack, you can open a Query all Records function. Next, go to the Output tab and select the "+ Addon" button underneath the response body.
2. Next, we will be given a choice to create a new Addon or choose to connect an existing one (if we previously created one).
3. Then, choose which database table to want to add to the response. This allows us to determine which data we want to add in our API request.
4. Choose how you'd like the data returned. There are several options that will be covered in the subsequent pages:
5. Now, select how to connect the database tables together. Here, we must determine how the tables are mapped together. This is usually done by a table reference to make a relationship between tables in our database. We can also add settings for sorting, paging, and distinct records during this step.
6. We can name the Addon or Xano will provide a default name.
7. Lastly, we can confirm how the Addon is mapped and optionally customize the values returned in the response.
Now we can see that the response will be extended with the Addon we created.
Finally, when we run the API endpoint. The response is extended with the data from another table thanks to the Addon!