Skip to main content

Module query

Module query 

Source
Expand description

SurrealQL statement builders.

Each builder is reached from Table (itself produced by the derived Type::table()) and rendered to a string with to_surrealql():

Mutations also offer then_select(...) to chain a reselect as a batch.

Structs§

Batch
Concatenates SurrealQL statements with ; separators. The store’s typical pattern is a mutation followed by a SELECT that re-projects the row.
Create
CREATE <target> [CONTENT … | SET …] [RETURN …].
DefineAnalyzer
DEFINE ANALYZER <name> TOKENIZERS <toks> FILTERS <filters> — a full-text tokenizer + filter pipeline (referenced by a SEARCH index).
DefineEvent
DEFINE EVENT <name> ON TABLE <table> WHEN <cond> THEN <block> — a trigger that fires on CREATE/UPDATE/DELETE. $event, $before, $after, $value are available inside when/then.
DefineFunction
DEFINE FUNCTION fn::<name>(<args>) -> <ret> { <body> } — a user-defined SurrealQL function. The fn:: prefix is added automatically.
DefineIndex
Builds a DEFINE INDEX statement — plain, composite, UNIQUE, full-text (SEARCH), or vector (HNSW/MTREE) indexes.
DefineParam
DEFINE PARAM $<name> VALUE <value> — a database-scoped parameter. The $ prefix is added automatically.
Delete
A DELETE <target> [WHERE …] [RETURN …] builder.
For
Builds a FOR $<var> IN <array> { <body> } loop. The loop variable $<var> is bound inside the body; push one or more statements as the body.
Insert
An INSERT INTO <table> … builder. Records are serialized inline as object literals; rendering requires T: serde::Serialize.
LetVar
Builds a LET $var = <expr> statement for session-scoped variables. The variable is available in subsequent queries within the same session.
Relate
Builds a graph edge statement RELATE a -> edge -> b for an edge type E. For edges that carry their own fields, see RelateEdge.
RelateEdge
Build a RELATE query with edge content.
Select
A SELECT statement builder: projections, WHERE, ORDER BY, LIMIT, START, FETCH, GROUP BY/GROUP ALL, count(), and the modifiers VALUE/OMIT/SPLIT/WITH/TIMEOUT/EXPLAIN.
Table
Entry point to the query builder for a record type T — the value returned by the derived T::table(). Each method starts a statement builder.
Transaction
Wraps statements in a SurrealDB transaction — BEGIN TRANSACTION; … ; COMMIT TRANSACTION;. Either every statement applies or none do: SurrealDB rolls the whole block back if any statement errors, and cancel terminates with CANCEL TRANSACTION to roll back explicitly. Unlike Batch (a plain ;-joined sequence), a transaction is atomic.
Update
An UPDATE/UPSERT builder: SET / MERGE / CONTENT, an optional WHERE, and RETURN. Built via Table::update or Table::upsert.

Enums§

Returning
How a mutating statement should return its affected rows.