Skip to main content

One post tagged with "dsl"

View All Tags

Graph Writes and Query DSL

· One min read
TeaQL Code Gen
Core Contributor

The Rust runtime now supports typed graph mutations and a fluent query DSL.

Typed Entity Graph Saves

let mut graph = EntityGraph::new();
graph.add(User::new().name("Alice"));
graph.add(Order::new().user_id("Alice.id"));

db.save_graph(&graph).await?;

The runtime validates foreign keys, plans insertion order, and executes within a transaction.

SQL Id Space Generator

let id_gen = SqlIdSpace::new("user_id_seq", 1000);
let batch = id_gen.next_batch(10).await?;

Reserves id ranges in bulk. Reduces database round-trips during bulk inserts.

Decimal for Aggregates

let total: Decimal = db.query(Order::total())
.filter(Order::status().eq("paid"))
.sum()
.await?;

rust_decimal replaces f64 for all aggregate results. Eliminates floating-point drift in financial calculations.

Query DSL

let users = db.query(User::class())
.filter(User::age().gte(18))
.order_by(User::created_at().desc())
.limit(20)
.list()
.await?;

Methods chain naturally. The macro expands field references into type-safe column identifiers at compile time.

Checker Events

Graph mutations emit checker events:

  • Pre-save validation
  • Post-save side effects
  • Rollback on failure

This hooks into the transactional planner for complex business rules.