Skip to content
🚀 This documentation is for unreal-orm 1.0.0 alpha which requires SurrealDB 2.0 alpha SDK. For the stable version, see npm.

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.

T

The TypeScript type of the expression result.

A SurrealQL expression (from surql template or Expr).

BoundQuery<unknown[]> | Expr

TypedExpr<T>

A TypedExpr that carries type information.

import { typed } from "unreal-orm";
import { surql } from "surrealdb";
// Simple computed field
const commentCount = typed<number>(surql`count(<-comment)`);
// Complex object
const stats = typed<{ views: number; likes: number }>(
surql`{ views: count(->view), likes: count(<-like) }`
);
// Graph traversal
const friends = typed<string[]>(surql`->follows->user.name`);