Skip to content
Krzysztof Słysz edited this page Dec 7, 2021 · 13 revisions

Rules

The rules are use to filter data. To create a rule, you can use base fields, properties and functions. You can combine rules to create more sophisticated filter.

An atomic rule can be define as:

  • three-element array e.g. ["id", ">", 0] - this is recomendded
  • string e.g. "id > 0" - created in case you need to use the native sql condition

The "rules" node must be defined in the request body as an array of rule.

{
  "rules": []
}

Missing the rule node, null value of the rule node or an empty array is treated as no rules.
By default, rules are treated as conjunction of all rules defined in the array.
The following rules:

{
  "rules": [
    ["id", ">", 10],
    ["$.name", "==", "John"]
  ]
}

are interpretted as:

id > 10 and $.name == "John"

There is also possibility to set manifestly the logical operator:

{
  "rules": [
    {
      "and": [
        ["id", ">", 10],
        ["$.name", "==", "John"]
      ]
    } 		
  ]
}

The above rules are also interpretted as:

id > 10 and $.name == "John"

You can also create nested rules:

{
  "rules": [
    ["id", ">", 10],
    ["$.name", "==", "John"],
    {
      "or": [
        ["$.age", ">", 18],
	["$.address.city", "like", "New%"]
      ]
    }	
  ]
}

The above rules are interpretted as:

id > 10 and $.name == "John" and ($.age > 18 or $.address.city like "New%")

To see more examples go to Rule examples page

Clone this wiki locally