ValenceImplemented
Policy-checked data models
Valence is a schema-driven ORM for Rust. Describe each model once, get typed APIs generated at build time, and every read and write is checked against that model's privacy policies for the user making the request.In both templates
Both templates store app data in Valence: SQLite in Embedded, IndraDB and Postgres in Remote fleet. Every admin app on this site reads and writes through it.Schema DSL
Implemented
Define fields, relationships, privacy policies, ownership, and backend routing with valence_schema!.
Generated Model APIs
Implemented
Generate typed reads, writes, queries, merges, and delete paths from application schemas at build time.
Declared data uses
Implemented
Every generated read and write takes a use_! purpose, so a call without one doesn't compile. A build-time scan collects every purpose into a catalog and flags vague ones.
Typed columns
Implemented
Store DateTime, Date, Decimal, Currency, enum and typed JSON fields alongside strings and integers.
Storage adapters
Implemented
Route models to memory, SQLite, Postgres, MongoDB, Redis, IndraDB, hybrid, or Surreal adapters through one runtime.
Privacy-aware data access
Implemented
Evaluate field and record policies on reads and writes, with default-deny behavior and user-scoped actors.
Deletion and table TTL
Implemented
Queue deletes, or call delete_now to remove a row and everything that depends on it right away. Cascades are privacy-checked, and configured tables expire on their own.
Valence Iter
Implemented
Declare an iter on a schema to sweep every row in the background. Progress and per-row failures are stored, and each run shows up in the operator UI.
Valence operator UI
Implemented
Inspect schemas, entities, privacy evaluation, traits, iterator runs, and deletion runs on this host at /valence.
See it in action
Code sample
Taken from the getting-started docs. See all code samples on Resources.
Valence schemaValence
Schema, generated model, and a read with a declared purpose
// build.rs
fn main() {
valence_codegen::build().expect("valence codegen failed");
}
// schemas/counter_valence_schema.rs
use valence::prelude::*;
valence_schema! {
Counter {
repository: "https://github.com/acme/counter",
table: "counter",
version: "0.1.0",
description: "Simple counter",
// No policies block: every actor except System is denied.
fields: [
id: { r#type: FieldType::String, primary_key: true, required: true },
value: { r#type: FieldType::Integer, required: true },
],
}
}
// src/lib.rs
use valence::{use_, Model};
valence::include_generated_models!();
let counter = Counter::get(
"home",
&valence,
use_!("Show the **counter value** on the home page."),
)
.await?;