Skip to main content

Module expr

Module expr 

Source
Expand description

The expression tree used inside WHERE/SET/projection clauses.

Values render to SurrealQL via the SurrealQL trait (literals) and the DynExpr trait (composed expressions). The building blocks include typed Column accessors, the untyped Ident, the Raw escape hatch, RecordLink (type::record(...)), Func calls, and comparison/logical operators that combine with .and() / .or().

Structs§

AndExpr
Column
A typed reference to a record field — e.g. Post::title() yields a Column<Post, String>. Generated by #[derive(SurrealRecord)] and used to build type-checked filters (.eq(...), .gt(...), …) and projections.
ColumnMeta
ColumnSet
Select-all (*) column list. Generated by #[derive(SurrealRecord)].
ContainsExpr
EqExpr
Func
A SurrealQL function call name(args…).
Grouped
Wraps an expression in parentheses: (<expr>). Use to force grouping/precedence.
GtExpr
GteExpr
Ident
An untyped identifier (column or field path) for building filter expressions where a typed Column accessor is unavailable (e.g. record-link fields the derive doesn’t expose, or tenant.slug paths). Mirrors Column’s operators.
IfExpr
A SurrealQL IF <cond> THEN <expr> [ELSE IF <cond> THEN <expr>]… [ELSE <expr>] END expression. As a DynExpr it nests anywhere an expression is taken — a SET value, a SELECT projection, a RETURN, or a WHERE.
InExpr
Literal
LtExpr
LteExpr
NeExpr
NoneLit
SurrealDB’s NONE.
NotExpr
NotInExpr
OrExpr
Param
A named SurrealQL parameter $name. In inline mode renders as a literal; in param mode (to_surrealql_with_params) renders as $name and collects the value. Use when you want to reference the same value in multiple places or give params meaningful names.
Path
A graph-traversal expression — e.g. ->wrote->post, <-wrote<-user, or a multi-hop chain with an optional .field/.* accessor at the end.
Projection
A single SELECT-list entry. Either a bare expression or <expr> AS <alias>.
Raw
A verbatim SurrealQL fragment. Use for expressions somnia does not model as typed nodes (e.g. IF x != NONE THEN … END, lambdas, tenant.slug).
RecordLink
Builds a SurrealDB record link type::record('table', <key>). The key is any literal value (typically the bare UUID/string id of the related row).

Enums§

Order
Sort direction for ORDER BY.

Traits§

DynExpr
A type-erased expression that can render itself into a SurrealQL buffer. Implemented by every expression node; the common currency of the builder.
Expr
A DynExpr that also reports a SurrealQL type hint. Auto-implemented for every DynExpr (returning "any"); concrete nodes may override the hint.
SurrealQL
A Rust type that can be rendered as a SurrealQL literal (the right-hand side of comparisons, SET values, etc.). Implemented for the common scalar types, Option<T>, serde_json::Value, the geometry types, and Thing<T>.

Functions§

col
A bare column name as a projection: name.
field
<raw> AS <alias> — verbatim expression with an alias.
ident
Construct an Ident for a field name.

Type Aliases§

DynExprBox
A boxed, type-erased expression. Useful for returning a composed filter from a helper function (e.g. a shared tenant/owner predicate).