Functions
/
Filter, Sort, Pagination (Reserved Parameters)

Filter, Sort, Pagination (Reserved Parameters)

Internal provides reserved parameters to support filtering, sorting, and pagination. For HTTP Functions, you may need to specify some or all of these parameters in the HTTP request so that Internal can retrieve the data correctly. 

These reserved parameters are automatically included in SQL Functions and MongoDB Functions, although some configuration is required for the latter.

Filters

You can configure filters for a HTTP Function by using the reserved filter parameter.  Path, URL parameters, and headers sections accept Javascript template literals so you will use the syntax ${filter.foo}.

Above: The reserved filter parameter is used in the path: ${filter.repo_name}. 


Once you add the reserved filter parameter, you’ll need to go to the Input section of the Function Editor to also add the filter there. 

Above: The filter “repo_name” is added to the Inputs section.


Filtering is automatically set for SQL Functions. For MongoDB Functions, you’ll simply need to add the names of the filterable fields in the Inputs section. There’s no need to use the  reserved parameter.

However, you can optionally use a reserved filter parameter in a MongoDB pipeline. Note that the aggregate pipeline requires JSON so use the syntax filter.name instead of ${filter.name}.

Above: The reserved parameter filter is used for this MongoDB Function.

Sorting

You can configure sorting for a HTTP request by using the reserved sortBy (string) and/or sortAscending (bool) parameter. Path, URL parameters, and headers sections accept Javascript template literals so you will use the syntax ${sortBy} and ${sortAscending}.

By default, Internal does not pass values for sortBy or sortAscending when viewing your data in a space. Check for undefined values to guard against this. For example, ${typeof sortBy === "undefined" ? "" : sortBy}



Above: The reserved parameter sortBy and sortAscending are used for this HTTP request. ${typeof sortBy === "undefined" ? "created_at" : sortBy} and sort_order: ${typeof sortAscending === "undefined" ? "asc" : (sortAscending ? "asc" : "desc")}


Sorting is automatically set for SQL Functions. For MongoDB Functions, you’ll simply need to add the names of the sortable fields in the Inputs section. There’s no need to use the  reserved parameter.

Pagination

You can configure pagination for a HTTP request by using the reserved pageNumber (int), pageOffset (int), and/or pageSize (int) parameter. Path, URL parameters, and headers sections accept Javascript template literals so you will use the syntax ${pageNumber}, ${pageOffset}, and ${pageSize}.

Above: The reserved parameter pageNumber and pageSize are used for this HTTP request: ${pageNumber} and ${pageSize}.

Pagination is auto set to 50 for MongoDB and SQL Functions. There’s no need to use reserved parameters.