Skip to main content

docbox_database/
lib.rs

1#![forbid(unsafe_code)]
2#![recursion_limit = "256"]
3
4// Pool re-exports
5pub use pool::{
6    DatabasePoolCache, DatabasePoolCacheConfig, DatabasePoolCacheConfigError, DbConnectErr,
7    DbSecrets,
8};
9
10/// SQLx re-exports for other projects
11pub use sqlx::{
12    self, PgExecutor as DbExecutor, PgPool, Postgres, Transaction,
13    postgres::{PgConnectOptions, PgPoolOptions},
14};
15
16pub mod create;
17pub mod migrations;
18pub mod models;
19pub mod pool;
20pub mod utils;
21
22/// Type of the database connection pool
23pub type DbPool = PgPool;
24
25/// Short type alias for a database error
26pub type DbErr = sqlx::Error;
27
28/// Type alias for a result where the error is a [DbErr]
29pub type DbResult<T> = Result<T, DbErr>;
30
31/// Type of a database transaction
32pub type DbTransaction<'c> = Transaction<'c, Postgres>;
33
34/// Name of the root database
35pub const ROOT_DATABASE_NAME: &str = "docbox";
36
37/// Name of the root database role
38pub const ROOT_DATABASE_ROLE_NAME: &str = "docbox_config_api";