Request Language
Request language
The request language is based upon JSON format. Any request or sub-request is an object. The object fields are either object properties to request or a combination operator (and, or).
A property type field is used to compare the property with the value and is also an object. This object must have only one field (with some exceptions). The field name is corresponding to a comparison operator and its value to the value to be compared with.
Some operators can manage
void values. In this case the value will be ignored.
Example:
{ "type": { "empty": null } }
One value.
Example:
{ "type": { "eq": 1 } }
Several values. Then, the field value will be a value table.
Example:
{ "type": { "in": [1,3,4] } }
Except for specific cases (cf. hereafter), the comparison between several values is a logical OR:
{ "status": { "eq": [4,5,7] } }
is equivalent to
{ "or": [ { "status": { "eq": 4 } }, { "status": { "eq": 5 } }, { "status": { "eq": 7 } } ] }
For negative operators, the comparison between several values is a logical and (not or):
{ "status": { "neq": [4,5,7] } }
is equivalent to
{ "and": [ { "status": { "neq": 4 } }, { "status": { "neq": 5 } }, { "status": { "neq": 7 } } ] }
Logical operators
OR
AND
NOT 11.21
A combination type operator field type is a table with sub requests, hence an object. Then if an object property bears the same name as a logical operator, you just need to indicate an object as the field value instead of a table.
"and": [] is a logical and
"and": {} is comparison of property named "and"
For NOT operator, the table expression items are combined with the operator OR.
{
"not": [
{"status":"6"},
{"activated":true}
]
}
is equivalent to
{
"not": [
{
"or":[
{"status":"6"},
{"activated":true}
]
}
]
}
If the table is doubled, expression items are combined with the operator AND.
{
"not": [[
{"status":"6"},
{"activated":true}
]]
}
is equivalent to
{
"not": [
{
"and":[
{"status":"6"},
{"activated":true}
]
}
]
}
The root object request creates a mandatory ‘and’ between all sub-queries.
{
"name": {
"sw": "A"
},
"status": {
"gte": 3
}
}
is equivalent to
{
"and":[ {
"name": {
"sw": "A"
}
},
{
"status": {
"gte": 3
}
}
]
}
It is also possible to combine several comparisons on a single field in one clause and
11.15.1
{
"date": {
"gte": "now",
"lt": "now(1)"
}
}
is equivalent to
{
"and":[
{
"date": {
"gte":"now"
}
},
{
"date": {
"lt": "now(1)"
}
}
]
}
Operators
Operators are not case sensitive. All operators are available in short or long version.
Long | Short | Definition |
---|---|---|
equals | eq | Equals to |
notequals | neq | Not equals to |
greaterthan | gt | Greater than |
greaterorequals | gte | Greater than or equals to |
lesserthan | lt | Lesser than |
lesserorequals | lte | Lesser than or equals to |
empty | e | Void or null |
notempty | ne | Non void and non null |
in | in | Belongs to |
notin | nin | Does not belong to |
startswith | sw | Starts with |
notstartswith | nsw | Does not start with |
endswith | ew | Ends with |
notendswith | new | Does not end with |
contains | ct | Contains |
notcontains | nct | Does not contains |
descendantof 11.10.2 | dof | Descendant of |
notdescendantof 11.21.2 | ndof | Not descendant of |
overlap11.19 | ovrl | Overlapping of two ranges |
Operators can use any type. The type value is adapted depending on the context.
E.g. all following expressions are equivalent:
{
"activated": {
"eq": true
}
}
{
"activated": {
"eq": "true"
}
}
{
"activated": {
"eq": "1"
}
}
{
"activated": {
"eq": 1
}
}
11.21 If the operator equals is used with value null, the operator used is empty. If the operator notequals is used with value null, the operator used is notempty.
Type: text, sentence, word, html
Long | Short | Definition | Multivalued |
---|---|---|---|
equals | eq | Equals to | yes |
notequals | neq | Not equals to | yes |
empty | e | Void or null | no |
notempty | ne | Non void and non null | no |
in | in | Belongs to | yes |
notin | nin | Does not belong to | yes |
startswith | sw | Starts with | yes |
notstartswith | nsw | Does not start with | yes |
endswith | ew | Ends with | yes |
notendswith | new | Does not end with | yes |
contains | ct | Contains | yes |
notcontains | nct | Does not contain | yes |
Type: number (integer or real)
Long | Short | Definition | Multivalued |
---|---|---|---|
equals | eq | Equals to | yes |
notequals | neq | Not equals to | yes |
greaterthan | gt | Greater than | yes |
greaterorequals | gte | Greater than or equals to | yes |
lesserthan | lt | Lesser than | yes |
lesserorequals | lte | Lesser than or equals to | yes |
empty | e | Void or null | no |
notempty | ne | Non void and non null | no |
Type: boolean
Long | Short | Definition | Multivalued |
---|---|---|---|
equals | eq | Equals to | yes |
notequals | neq | Not equals to | yes |
empty | e | Void or null | no |
notempty | ne | Non void and non null | no |
Type: timestamp (dates)
The value is automatically converted to the appropriate type according to the type of the compared field (date or datetime). The dates comparison values could be set in JavaScript timestamp (as long) or using simple ISO strings.
Long | Short | Definition | Multivalued |
---|---|---|---|
equals | eq | Equals to | yes |
notequals | neq | Not equals to | yes |
greaterthan | gt | Greater than | yes |
greaterorequals | gte | Greater than or equals to | yes |
lesserthan | lt | Lesser than | yes |
lesserorequals | lte | Lesser than or equals to | yes |
empty | e | Void or null | no |
notempty | ne | Non void and non null | no |
Value and format
The dates comparison values could be set in JavaScript timestamp (as long) or using simple ISO strings.
{
"datetime": {
"eq": 1552405738000
}
}
{
"date": {
"eq": "20160308"
}
}
{
"datetime": {
"eq": "20160308T124223"
}
}
Functions
Function now allows to compare to now or relative dates. Specify the difference in days between brackets (negative numbers for earlier dates and positive numbers for later dates):
now
ornow(0)
: means todaynow(-1)
: means yesterdaynow(1)
ornow(+1)
: means tomorrow
{ "date": { "eq": "now(-10)" } } { "datetime": { "gt": "now" } }
Function today allows you compare to today or relative dates. The difference with function now is that for today the generated date is always of type date, while for now the type is date or datetime depending on the type of the property being compared.
Function ts allows to compare to a timestamp within a string context (like request parameter)
11.19
For example:
ts(1552405738000)
.The value is automatically converted to the appropriate type according to the type of the compared field (date or datetime).
Type: path (resource)
Path for resources can use slash (/) or backslash (\) indifferently.
Long | Short | Definition | Multivalued |
---|---|---|---|
equals | eq | Equals to | yes |
notequals | neq | Not equals to | yes |
empty | e | Void or null | no |
notempty | ne | Non void and non null | no |
startswith | sw | Starts with | yes |
notstartswith | nsw | Does not start with | yes |
endswith | ew | Ends with | yes |
notendswith | new | Does not end with | yes |
contains | ct | Contains | yes |
notcontains | nct | Does not contains | yes |
Type: object
The test value shall be an object identifier or void for empty or not empty.
Long | Short | Definition | Multivalued |
---|---|---|---|
equals | eq | Equals to | yes |
notequals | neq | Not equals to | yes |
empty | e | Void or null | no |
notempty | ne | Non void and non null | no |
in | in | Belongs to | yes |
notin | nin | Does not belong to | yes |
descendantof | dof | Descendant of | yes |
notdescendantof | ndof | Not descendant of | yes |
Type: array
Long | Short | Definition | Multivalued |
---|---|---|---|
empty | e | Void or null | no |
notempty | ne | Non void and non null | no |
in | in | Belongs to | yes |
notin | nin | Does not belong to | no |
contains | ct | Contains | yes |
notcontains | nct | Contains | yes |
descendantof | dof | Descendant of | yes |
notdescendantof | ndof | Not descendant of | yes |
Type: identity
Long | Short | Definition | Multivalued |
---|---|---|---|
equals | eq | Equals to | yes |
notequals | neq | Not equals to | yes |
greaterthan | gt | Greater than | yes |
greaterorequals | gte | Greater than or equals to | yes |
lesserthan | lt | Lesser than | yes |
lesserorequals | lte | Lesser than or equals to | yes |
empty | e | Void or null | no |
notempty | ne | Non void and non null | no |
in | in | Belongs to | yes |
notin | nin | Does not belong to | yes |
Type: uuid
It is possible to make queries on the uuid, even though it is not a field per se of an instance. Simply specify $uuid
in the property name.
Long | Short | Definition | Multivalued |
---|---|---|---|
equals | eq | Equals to | yes |
notequals | neq | Not equals to | yes |
greaterthan | gt | Greater than | yes |
greaterorequals | gte | Greater than or equals to | yes |
lesserthan | lt | Lesser than | yes |
lesserorequals | lte |