typed
typed<
T>(expr):TypedExpr<T>
Defined in: define/table/types/select.ts:66
Creates a typed SurrealQL expression for use in select queries. The type parameter specifies the expected return type of the expression.
Type Parameters
Section titled “Type Parameters”T
The TypeScript type of the expression result.
Parameters
Section titled “Parameters”A SurrealQL expression (from surql template or Expr).
BoundQuery<unknown[]> | Expr
Returns
Section titled “Returns”TypedExpr<T>
A TypedExpr that carries type information.
Example
Section titled “Example”import { typed } from "unreal-orm";import { surql } from "surrealdb";
// Simple computed fieldconst commentCount = typed<number>(surql`count(<-comment)`);
// Complex objectconst stats = typed<{ views: number; likes: number }>( surql`{ views: count(->view), likes: count(<-like) }`);
// Graph traversalconst friends = typed<string[]>(surql`->follows->user.name`);