pub struct Database { /* private fields */ }Expand description
Database connection pool with migration support.
Implementations§
Source§impl Database
impl Database
Sourcepub fn open(path: &Path) -> Result<Self, DbError>
pub fn open(path: &Path) -> Result<Self, DbError>
Open (or create) a database at the given path with WAL mode and FK enforcement.
Sourcepub fn open_in_memory() -> Result<Self, DbError>
pub fn open_in_memory() -> Result<Self, DbError>
Open an in-memory database (for testing).
Sourcepub fn migrate(&self) -> Result<(), DbError>
pub fn migrate(&self) -> Result<(), DbError>
Run all pending migrations, then backfill any paper rows that
lack a stable bibtex_key (#132). The backfill is idempotent —
on every subsequent call it’s a no-op because every paper
already has a key. Papers gain keys via save/save_many
thereafter, keeping this migrate-call the only place that
needs to know about the assignment algorithm.
Sourcepub fn conn(&self) -> Result<PooledConnection<SqliteConnectionManager>, DbError>
pub fn conn(&self) -> Result<PooledConnection<SqliteConnectionManager>, DbError>
Get a connection from the pool.
Sourcepub fn repositories(
&self,
) -> (SqlitePaperRepository, SqliteSearchRepository, SqliteQuestionRepository, SqliteAssessmentRepository, SqliteCitationRepository)
pub fn repositories( &self, ) -> (SqlitePaperRepository, SqliteSearchRepository, SqliteQuestionRepository, SqliteAssessmentRepository, SqliteCitationRepository)
Create all repository instances sharing this database.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Database
impl !UnwindSafe for Database
impl Freeze for Database
impl Send for Database
impl Sync for Database
impl Unpin for Database
impl UnsafeUnpin for Database
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more