prorm API Reference
    Preparing search index...

    Class CaseBuilder

    Fluent builder for a "searched" CASE expression: CASE WHEN cond1 THEN result1 WHEN cond2 THEN result2 ... ELSE else END

    Build with caseWhen(). Terminate with .as(alias) (for use directly in an attributes: [...] array) or .toSQL() / .toLiteral().

    Index
    • Add a WHEN <condition> THEN <thenValue> branch. Repeatable — call multiple times to add multiple branches, evaluated in order.

      Two call forms are supported:

      • .when(conditionObject, thenValue) — condition object using the same shape as where: clauses ({ age: { [Op.gte]: 18 } }, nested Op.and/Op.or, etc.)
      • .when(column, operator, value, thenValue) — ergonomic shorthand for a single comparison (mirrors Op.where(col, op, value)).

      Parameters

      Returns this

    • Add a WHEN <condition> THEN <thenValue> branch. Repeatable — call multiple times to add multiple branches, evaluated in order.

      Two call forms are supported:

      • .when(conditionObject, thenValue) — condition object using the same shape as where: clauses ({ age: { [Op.gte]: 18 } }, nested Op.and/Op.or, etc.)
      • .when(column, operator, value, thenValue) — ergonomic shorthand for a single comparison (mirrors Op.where(col, op, value)).

      Parameters

      Returns this

    • Terminal call: returns an [expr, alias] tuple compatible with the existing attributes: [...] pattern (see attributeToSql() in sql-compiler.ts, which already knows how to render [LiteralExpression, alias] tuples without any core changes).

      Parameters

      • alias: string

      Returns [LiteralExpression, string]