Query language
Corteza implements an SQL-like syntax for querying and sorting records.
Querying
The general template for constructing a query looks like this:
FIELD OPERATOR VALUE [AND|OR FIELD OPERATOR VALUE [...]]
For the following examples, let us assume that we have a module named test
with the following fields:
-
quantity
of typeNumber
-
price
of typeNumber
-
name
of typeString
-
visible
of typeCheckbox
To query for records with zero quantity or zero price:
quantity = 0 or price = zero
To query all visible records starting with the letter "a":
visible AND name LIKE 'a%'
Sorting
The general template for constructing a sort looks like this:
FIELD[ DIRECTION][, FIELD[ DIRECTION] [...]]
Supported directions:
-
ASC
: sort in ascending order, lower values first (NULL
values are first). This is the default sort if noDIRECTION
is specified. -
DESC
: sort in ascending order, lower values last (NULL
values are last).
For the following examples, let us assume that we have a module named test
with the following fields:
-
quantity
of typeNumber
-
price
of typeNumber
-
name
of typeString
-
visible
of typeCheckbox
To order records, descending by price and ascending by quantity:
price DESC, quantity