Spanish Total.js
English
Documentation For AI agents
Contents

View definition

Every key of the JSON that defines a view.

.md GitHub
On this page

A view is a JSON object that you write in the View specification editor. See Create a view.

View keys

KeyRequiredWhat it does
idYesA unique ID, for example orders. A view with the same id replaces the old one.
nameYesThe name in the Views screen and in the View list of reports.
sqlYesA PostgreSQL SELECT that returns the data.
fieldsYesThe fields people can use, as a list of objects (below).

Field keys

KeyRequiredWhat it does
columnYesA column returned by sql.
nameYesThe name people see in reports and column headers.
typeYesstring, number, boolean or date. It decides the filter types and how values show.
groupNotrue lets reports group by this field.
formatNoFor number fields: the number of decimals to show, for example 2.
outputNoThe ID of the field in reports and in the API. "@" uses the column name. Without it, OpenReports makes an ID from the column, such as xfu9n6e.

Field IDs

Reports and the API refer to fields by their ID. Set output when you want readable IDs in the API, or when you may rename the column later: the ID then stays the same. See Edit and remove views.

Example

{
    "id": "orders",
    "name": "Orders",
    "sql": "SELECT customer, country, total, dtcreated FROM demo_orders",
    "fields": [
        { "column": "customer", "name": "Customer", "type": "string", "group": true },
        { "column": "country", "name": "Country", "type": "string", "group": true },
        { "output": "total", "column": "total", "name": "Total", "type": "number", "format": 2 },
        { "column": "dtcreated", "name": "Created", "type": "date", "group": true }
    ]
}
Made in Europe