Skip to main content

Module database

Module database 

Source
Expand description

The application’s Toasty database.

Models are Rust structs with #[derive(toasty::Model)]; this module opens the connection pool they run on, on PostgreSQL. Configure it with DATABASE_URL (default DEFAULT_URL). Several processes and machines can share the database.

Schema changes are Toasty migrations: generated from the models by the app’s migrate binary (built on toasty-cli) and applied by it.

Structs§

DatabaseConfig
Where to connect.

Enums§

IsolationLevel
Transaction isolation levels, for toasty::TransactionBuilder::isolation. Serializable transactions may fail with a serialization failure under contention; retry them (SERIALIZABLE_ATTEMPTS). SQL transaction isolation levels.

Constants§

DEFAULT_URL
The database used when DATABASE_URL is not set: a local PostgreSQL.
SERIALIZABLE_ATTEMPTS
How many times to run a Serializable transaction that keeps failing with a serialization failure before giving up.
URL_ENV
Environment variable holding the database URL.

Functions§

connect
Opens a pooled handle to the database for models. Cheap to clone: clones share the pool.