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}.
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.
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}.
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}
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}.
Note:
Pagination is auto set to 50 for MongoDB and SQL Functions. There’s no need to use reserved parameters.
Updated about 1 year ago