Expand description
§somnia-core — typed SurrealQL query builder
The core of the somnia SurrealDB ORM: a typed query
builder, an expression tree, and the record/schema traits. Most users depend on
the somnia umbrella crate (which re-exports everything here) rather than on
somnia-core directly.
The builder renders ready-to-run SurrealQL strings via to_surrealql(), inlining
literals with proper escaping rather than relying on bind parameters.
§Modules
types—Key,Thing, the geometry types, and theSurrealRecord/SurrealEdge/SurrealSchematraits.expr— the expression tree: literals,Column,Ident,Raw,RecordLink, operators, and theSurrealQLliteral-rendering trait.query— statement builders:Table,Select,Create,Update,Delete,Insert,Relate, andBatch.error— the crate error type.
§Example
ⓘ
// `Post` derives `SurrealRecord`, which generates `table()`, `all()`,
// and typed column accessors like `Post::title()`.
let sql = Post::table()
.select(Post::all())
.filter(Post::title().eq("hello".to_string()))
.limit(10)
.to_surrealql();Re-exports§
pub use expr::col;pub use expr::field;pub use expr::ident;pub use expr::Column;pub use expr::ColumnMeta;pub use expr::ColumnSet;pub use expr::DynExpr;pub use expr::DynExprBox;pub use expr::Expr;pub use expr::Func;pub use expr::Grouped;pub use expr::Ident;pub use expr::IfExpr;pub use expr::NoneLit;pub use expr::Order;pub use expr::Param;pub use expr::Path;pub use expr::Projection;pub use expr::Raw;pub use expr::RecordLink;pub use expr::SurrealQL;pub use query::Batch;pub use query::Create;pub use query::DefineAnalyzer;pub use query::DefineEvent;pub use query::DefineFunction;pub use query::DefineIndex;pub use query::DefineParam;pub use query::Delete;pub use query::For;pub use query::Insert;pub use query::LetVar;pub use query::Relate;pub use query::RelateEdge;pub use query::Returning;pub use query::Select;pub use query::Table;pub use query::Transaction;pub use query::Update;pub use types::Key;pub use types::SurrealEdge;pub use types::SurrealRecord;pub use types::SurrealSchema;pub use types::Thing;