Expand description
The application’s SurrealDB database.
The app connects to a SurrealDB server (self-hosted or SurrealDB Cloud)
over WebSocket and runs SurrealQL through the surrealdb SDK. Several
processes and machines can share the database. Configure it with
SURREAL_URL, SURREAL_NS, SURREAL_DB, SURREAL_USER, SURREAL_PASS
and SURREAL_AUTH_LEVEL (see DatabaseConfig::from_env).
Schema changes are SurrealQL files in database/migrations/, applied in
order by migrations.
Modules§
- migrations
- Schema migrations: SurrealQL files applied in order.
Structs§
- Database
Config - Where to connect and how to sign in.
Enums§
- Auth
Level - Where a SurrealDB user is defined, which decides how to sign in.
Constants§
- AUTH_
LEVEL_ ENV - DATABASE_
ENV - DEFAULT_
URL - The server used when
SURREAL_URLis not set:surreal starton this machine. - NAMESPACE_
ENV - PASSWORD_
ENV - TRANSACTION_
ATTEMPTS - How many times
transaction!runs a transaction that keeps failing with a conflict (seeis_transaction_conflict) before giving up. - URL_ENV
- USER_
ENV
Traits§
- Executor
- Runs SurrealQL: the database (
Db) or aTransaction. Write helper functions against&impl Executorto use them in and out of transactions. - Maybe
Conflict - Errors that may be a transaction conflict, so
transaction!knows when to retry.
Functions§
- connect
- Connects, signs in and selects the namespace and database.
- is_
already_ exists - Whether
erris a write rejected by aUNIQUEindex or an existing record ID. - is_
transaction_ conflict - Whether
erris a transaction that lost a race with a concurrent one; running it again usually succeeds (up toTRANSACTION_ATTEMPTStimes).
Type Aliases§
- Db
- A connection to the database. Cheap to clone: clones share the connection.
- Transaction
- A transaction started by
transaction!.