Skip to main content

somnia_core/
lib.rs

1//! # somnia-core — typed SurrealQL query builder
2//!
3//! The core of the [somnia](https://docs.rs/somnia) SurrealDB ORM: a typed query
4//! builder, an expression tree, and the record/schema traits. Most users depend on
5//! the `somnia` umbrella crate (which re-exports everything here) rather than on
6//! `somnia-core` directly.
7//!
8//! The builder renders ready-to-run SurrealQL strings via `to_surrealql()`, inlining
9//! literals with proper escaping rather than relying on bind parameters.
10//!
11//! ## Modules
12//!
13//! - [`types`] — [`Key`], [`Thing`], the geometry types, and the
14//!   [`SurrealRecord`] / [`SurrealEdge`] / [`SurrealSchema`] traits.
15//! - [`expr`] — the expression tree: literals, [`Column`], [`Ident`], [`Raw`],
16//!   [`RecordLink`], operators, and the [`SurrealQL`] literal-rendering trait.
17//! - [`query`] — statement builders: [`Table`], [`Select`], [`Create`], [`Update`],
18//!   [`Delete`], [`Insert`], [`Relate`], and [`Batch`].
19//! - [`error`] — the crate error type.
20//!
21//! ## Example
22//!
23//! ```ignore
24//! // `Post` derives `SurrealRecord`, which generates `table()`, `all()`,
25//! // and typed column accessors like `Post::title()`.
26//! let sql = Post::table()
27//!     .select(Post::all())
28//!     .filter(Post::title().eq("hello".to_string()))
29//!     .limit(10)
30//!     .to_surrealql();
31//! ```
32
33pub mod error;
34pub mod expr;
35pub mod query;
36pub mod types;
37
38pub use expr::{
39    col, field, ident, Column, ColumnMeta, ColumnSet, DynExpr, DynExprBox, Expr, Func, Grouped,
40    Ident, IfExpr, NoneLit, Order, Param, Path, Projection, Raw, RecordLink, SurrealQL,
41};
42pub use query::{
43    Batch, Create, DefineAnalyzer, DefineEvent, DefineFunction, DefineIndex, DefineParam, Delete,
44    For, Insert, LetVar, Relate, RelateEdge, Returning, Select, Table, Transaction, Update,
45};
46pub use types::{Key, SurrealEdge, SurrealRecord, SurrealSchema, Thing};