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():
Select—SELECT … FROM …Create—CREATE …Insert—INSERT INTO …Update—UPDATE …(andUPSERT …viaTable::upsert)Delete—DELETE …Relate/RelateEdge—RELATE a -> edge -> bBatch— several statements joined with;
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 …].- Define
Analyzer DEFINE ANALYZER <name> TOKENIZERS <toks> FILTERS <filters>— a full-text tokenizer + filter pipeline (referenced by aSEARCHindex).- Define
Event DEFINE EVENT <name> ON TABLE <table> WHEN <cond> THEN <block>— a trigger that fires onCREATE/UPDATE/DELETE.$event,$before,$after,$valueare available insidewhen/then.- Define
Function DEFINE FUNCTION fn::<name>(<args>) -> <ret> { <body> }— a user-defined SurrealQL function. Thefn::prefix is added automatically.- Define
Index - Builds a
DEFINE INDEXstatement — plain, composite,UNIQUE, full-text (SEARCH), or vector (HNSW/MTREE) indexes. - Define
Param 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 requiresT: 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 -> bfor an edge typeE. For edges that carry their own fields, seeRelateEdge. - Relate
Edge - Build a RELATE query with edge content.
- Select
- A
SELECTstatement builder: projections,WHERE,ORDER BY,LIMIT,START,FETCH,GROUP BY/GROUP ALL,count(), and the modifiersVALUE/OMIT/SPLIT/WITH/TIMEOUT/EXPLAIN. - Table
- Entry point to the query builder for a record type
T— the value returned by the derivedT::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, andcancelterminates withCANCEL TRANSACTIONto roll back explicitly. UnlikeBatch(a plain;-joined sequence), a transaction is atomic. - Update
- An
UPDATE/UPSERTbuilder:SET/MERGE/CONTENT, an optionalWHERE, andRETURN. Built viaTable::updateorTable::upsert.
Enums§
- Returning
- How a mutating statement should return its affected rows.