Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you don't need to perform searches based on the components of rules then you can store the rule in two fields in the database. The condition under which the statement gets executed in one and the statement that is executed in another.</p> <pre><code>id, name, description, condition, statement </code></pre> <p>Your rules can be stored using JSON or some similar format.</p> <p>I'll need to define some terminology that I'll be using. There are <strong>atomic terms</strong>, system values compared to values inputted by the user that evaluate to true/false, and <strong>complex terms</strong>, terms combined using logical operators.</p> <p>In an <strong>atomic term</strong>, <strong>var</strong> denotes a value that the system will provide (such as the number of visitors or number of unique visitors). <strong>Comparisons</strong> determine how the <strong>var</strong> is to be evaluated against the <strong>value</strong>. The <strong>value</strong> is a number or string that the user produces. When a var and value are both numbers, comparisons can be "&lt;", "&lt;=", "=", ">=", or ">". When a var and value are both strings, comparisons can be "equals", "begins with", "ends with", or "contains". Atomic terms can be stored as follows:</p> <pre><code>{ var: varName, comp: comparison, value: numberOrString } </code></pre> <p>You can store the complex terms consisting of conjunctions, disjunctions, and negations (and/or/not) using the following formats.</p> <pre><code>// Conjunction { op: "and", terms: [ term, ..., term ] } // Disjunction { op: "or", terms: [ term, ..., term ] } // Negation { op: "not", term: term } </code></pre> <p>You can then build statements that evaluate to true/false using these methods. An example is as follows:</p> <pre><code>{ op: "and", terms: [ {op "or", terms: [ { field: "numVisitors", comp: "&gt;", value: 1000 }, { field: "numUniqueVisitors", comp: "&gt;=" 100 } ]}, { op: "not", term: { { field: "numVisitors", comp: "&lt;", value: 500 } }} ]} </code></pre> <p>The example above equates to true when the number of visitors is greater than 1000 or the number of unique visitors is greater than or equal to 100, and the number of visitors is not less than 500.</p> <p>You can then execute what you refer to as a "statement" when the rule evaluates to true.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload