Build a complete Rent application
The core sequence follows one User → Post → Comment application and introduces one new concern at a time:
- Define the schema in RSL: fields, IDs, relationships, and explicit generation.
- Create, read, update, and delete: generated create inputs, fluent builders, exact-cardinality reads, and execution boundaries.
- Load relationships: posts, comments, traversal, eager loading, explicit load state, one-to-one relations, and atomic nested creates.
- Model many-to-many data: implicit join tables, explicit membership entities, connect, disconnect, and traversal.
- Query collections: typed filters, ordering, offsets, opaque keyset cursors, projections, aggregates, and grouping.
- Run transactions: closure-based commit, rollback, application error types, and middleware propagation.
- Recover with savepoints: partial rollback, release, and portable savepoint validation.
- Prevent stale writes: automatic version predicates, increments, and dedicated conflict errors.
- Lock rows: pessimistic locking and explicit backend capability errors.
- Isolate tenants: request viewers, automatic tenant filters and values, cross-tenant denial, bulk writes, and transactions.
- Compose middleware: policies, query interceptors, mutation hooks, ordering, rewriting, and rejection.
- Use rich types: JSON, UUIDs, time, bytes, enums, signed and unsigned values, and backend-safe encoding.
- Encrypt fields: typed field registration, transparent AES-256-GCM transforms, and ciphertext-at-rest verification.
- Store external blobs: object repositories, lazy reads, tenant encryption, dual writes, and orphan cleanup.
- Manage database objects: views, generated columns, triggers, row-level security, policies, and domains.
- Evolve the schema: inspection, diff, safety, apply, table and column identity, preserved rows, and fixed points.
- Upsert and customize IDs: typed conflict targets, custom IDs, and compound identities.
- Enforce integrity: foreign keys, uniqueness, checks, cascades, and
SET NULL. - Configure production schemas: compound foreign keys, custom join storage, SQL defaults, and advanced indexes.
- Configure the runtime: pool bounds, timeouts, structured tracing, retryable transactions, and safe shutdown behavior.
- Write in bulk and measure overhead: single-request multi-row inserts, atomic failure, pagination after bulk load, and repeatable SQLx comparisons.
- Inspect local data with Studio: browse schemas and rows, then opt into primary-key-safe fixture edits.
- Add PostgreSQL capabilities: fourteen focused applications for queues, schedules, HTTP, vectors, spatial data, time series, search, validation, partitioning, cryptography, IDs, and auditing.
Every chapter is self-contained. Its Rust binary lives at crates/rent/examples/<chapter>.rs, its focused schema
lives at crates/rent/examples/<chapter>/schema.rsl, and chapters that use the typed client check generated Rust
into crates/rent/examples/<chapter>/generated. Schemas intentionally repeat earlier declarations so a beginner
never has to understand an unrelated, application-sized model to run one lesson.
Cargo does not generate examples as a build side effect. Run scripts/generate-examples.sh after editing a chapter
schema; CI runs scripts/generate-examples.sh --check to reject stale checked-in clients. Each program's main
function and embedded nextest test call the same exercise() function, so schema, generated API, documentation
behavior, and test behavior drift together and fail visibly.
Start with Define the schema in RSL. Run the entire curriculum with cargo nextest run -p rent --all-targets.