Query

Its possible to call query api from the applications. In this template we can create sql queries against precreated database tables.

In order to use this feature the applications needs to register access for its tables beforehand.

Create a template with type ‘query’.

Usage

The query calls can only be used from function templates and cannot be directly called from pages or routes.

{{ $res = .Tools.AppData.RunQuery "demo-app-bulk-query" }}

We can pass parameters to the query after the template name. There is no limit to the amount of parameters.

{{ $res = .Tools.AppData.RunQuery "demo-app-bulk-query" $arg1 }}

Methods

There are 2 diffrent ways to call queries: single or bulk.

  1. Single - A single query call Single queries
  2. Bulk - Contains multiple calls in a single query template, optionally the calls can be sent in a single transaction. Bulk queries

Results

Result is given as gjson.Result type. We can then read it similar to dynamic api results.

{{ $res = .Tools.AppData.RunQuery "demo-app-single-query" }}
{{ $v := $res.Get "id" }}