Command Palette

Search for a command to run...

Conditional Logic

Edges in Treege support conditional logic based on field values. You can combine multiple conditions using AND/OR operators to create complex workflow.

Basic Structure

{
  id: "e1",
  source: "source-node-id",
  target: "target-node-id",
  conditions: {
    operator: "AND" | "OR",
    rules: [
      {
        field: "field-id",
        operator: "===" | "!==" | ">" | "<" | ">=" | "<=",
        value: any
      }
    ]
  }
}

Supported Operators

| Operator | Description      | Example                 |
|----------|------------------|-------------------------|
| `===`    | Equals           | `age === 18`            |
| `!==`    | Not equals       | `status !== "inactive"` |
| `>`      | Greater than     | `score > 80`            |
| `<`      | Less than        | `price < 100`           |
| `>=`     | Greater or equal | `age >= 21`             |
| `<=`     | Less or equal    | `items <= 5`            |

Examples

Simple Condition

{
  id: "e1",
  source: "ticket-type",
  target: "meal-preference",
  conditions: {
    operator: "AND",
    rules: [
      {
        field: "ticket-type",
        operator: "===",
        value: "vip"
      }
    ]
  }
}

OR Conditions

{
  id: "e2",
  source: "ticket-type",
  target: "meal-preference",
  conditions: {
    operator: "OR",
    rules: [
      { field: "ticket-type", operator: "===", value: "vip" },
      { field: "ticket-type", operator: "===", value: "regular" }
    ]
  }
}

AND Conditions

{
  id: "e3",
  source: "age",
  target: "alcohol-preference",
  conditions: {
    operator: "AND",
    rules: [
      { field: "age", operator: ">=", value: 21 },
      { field: "country", operator: "===", value: "US" }
    ]
  }
}