WeaveKit Docs
GuidesModel

Formulas

Computed, stored-on-write field values: operators, functions, aggregations and null semantics.

A formula computes a read-only field value on write, and the result is stored. Formulas work on six scalar types: string, text, number, currency, integer, and boolean.

{ "name": "total",  "type": "currency", "formula": "quantity * unit_price" },
{ "name": "label",  "type": "string",   "formula": "doc_no & \" / \" & title" },
{ "name": "is_big", "type": "boolean",  "formula": "total > 1000" }

Operators

GroupOperators
Arithmetic+ - * / and parentheses
Comparison= != < <= > >=
LogicAND OR NOT
String concat&

Functions

IF(cond, a, b), ROUND(x), NOW(), CONCAT(...).

Aggregations over detail rows

{ "name": "lines_total", "type": "currency", "formula": "SUM(lines.amount)" }

COUNT and SUM work over a details child. AVG skips null values.

Cross-object references

One level deep, referencing a scalar on a relation target:

{ "name": "supplier_label", "type": "string", "formula": "supplier_id.name" }

Cross-object references obey RBAC: if the subject can't read the referenced target (object read permission + row scope + field exclude), the reference resolves to null rather than leaking data — see RBAC.

Null semantics

ExpressionResult
arithmetic with a null operandnull
comparison with nullfalse
string concat with null''
SUM/AVG over nullsnulls skipped

Rules

  • A formula field is read-only: no required, unique, default, primary, or constraints.
  • References must resolve to scalar fields (no relations, and no aggregates of aggregates beyond one level).
  • Cycles — including cross-object — are rejected at schema build time.
  • When a dependency changes, the field is recomputed and persisted on the next write.

On this page