Skip to content
Concepts

Database concepts

A writing app starts with users and posts. Soon it needs to load an author's posts, save an edit without losing someone else's work, and decide who can read a draft. The guides here explain those ideas through small schemas and Rust examples.

Model and query your data

Start with CRUD and relationships. Then choose field types and storage, adjust schema options, and share common declarations with model mixins.

The constraints and advanced SQL guide connects IDs, upserts, uniqueness, pagination, aggregates, views, domains, generated columns, triggers, and raw SQL to the tasks they help solve. Database portability explains what stays the same across databases and where to choose a database-specific capability.

Use transactions when changes must succeed together, including savepoints and row locks when you need them. Use optimistic locking when two people might edit the same record. Runtime and observability covers connection pools, tracing, and diagnosing database work.

Decide who can access the data

Start with tenancy and permissions to see how customer isolation and resource access work together, and where custom application policies fit.

Tenancy keeps each customer's rows separate. Optional relationship permissions describe ownership, sharing, and inherited access. Permission profiles let several resource types reuse those rules.

Scoped clients give request code the authority of the person making the request. Policies, interceptors, and hooks add application-specific restrictions and behavior around reads and writes.

For a complete application walkthrough, follow the examples. What's new collects recent guides and release notes.