pub struct ThingsDatabase { /* private fields */ }
Expand description
SQLx-based database implementation for Things 3 data This provides async, Send + Sync compatible database access
Implementations§
Source§impl ThingsDatabase
impl ThingsDatabase
Sourcepub async fn new(database_path: &Path) -> ThingsResult<Self>
pub async fn new(database_path: &Path) -> ThingsResult<Self>
Create a new database connection pool with default configuration
§Errors
Returns an error if the database connection fails or if SQLite
configuration fails
Sourcepub async fn new_with_config(
database_path: &Path,
config: DatabasePoolConfig,
) -> ThingsResult<Self>
pub async fn new_with_config( database_path: &Path, config: DatabasePoolConfig, ) -> ThingsResult<Self>
Create a new database connection pool with custom configuration
§Errors
Returns an error if the database connection fails or if SQLite
configuration fails
Sourcepub async fn from_connection_string(database_url: &str) -> ThingsResult<Self>
pub async fn from_connection_string(database_url: &str) -> ThingsResult<Self>
Create a new database connection pool from a connection string with default configuration
§Errors
Returns an error if the database connection fails or if SQLite
configuration fails
Sourcepub async fn from_connection_string_with_config(
database_url: &str,
config: DatabasePoolConfig,
) -> ThingsResult<Self>
pub async fn from_connection_string_with_config( database_url: &str, config: DatabasePoolConfig, ) -> ThingsResult<Self>
Create a new database connection pool from a connection string with custom configuration
§Errors
Returns an error if the database connection fails or if SQLite
configuration fails
Sourcepub fn pool(&self) -> &SqlitePool
pub fn pool(&self) -> &SqlitePool
Get the underlying connection pool
Sourcepub async fn is_connected(&self) -> bool
pub async fn is_connected(&self) -> bool
Check if the database is connected
Sourcepub async fn get_pool_health(&self) -> ThingsResult<PoolHealthStatus>
pub async fn get_pool_health(&self) -> ThingsResult<PoolHealthStatus>
Sourcepub async fn get_pool_metrics(&self) -> ThingsResult<PoolMetrics>
pub async fn get_pool_metrics(&self) -> ThingsResult<PoolMetrics>
Sourcepub async fn comprehensive_health_check(
&self,
) -> ThingsResult<ComprehensiveHealthStatus>
pub async fn comprehensive_health_check( &self, ) -> ThingsResult<ComprehensiveHealthStatus>
Perform a comprehensive health check including pool and database
§Errors
Returns an error if the health check fails
Sourcepub async fn get_stats(&self) -> ThingsResult<DatabaseStats>
pub async fn get_stats(&self) -> ThingsResult<DatabaseStats>
Sourcepub async fn get_all_tasks(&self) -> ThingsResult<Vec<Task>>
pub async fn get_all_tasks(&self) -> ThingsResult<Vec<Task>>
Sourcepub async fn get_all_projects(&self) -> ThingsResult<Vec<Project>>
pub async fn get_all_projects(&self) -> ThingsResult<Vec<Project>>
Get all projects (from TMTask
table where type = 1)
§Errors
Returns an error if the database query fails or if project data is invalid
Sourcepub async fn get_all_areas(&self) -> ThingsResult<Vec<Area>>
pub async fn get_all_areas(&self) -> ThingsResult<Vec<Area>>
Sourcepub async fn get_tasks_by_status(
&self,
status: TaskStatus,
) -> ThingsResult<Vec<Task>>
pub async fn get_tasks_by_status( &self, status: TaskStatus, ) -> ThingsResult<Vec<Task>>
Sourcepub async fn search_tasks(&self, query: &str) -> ThingsResult<Vec<Task>>
pub async fn search_tasks(&self, query: &str) -> ThingsResult<Vec<Task>>
Search tasks by title or notes
§Errors
Returns an error if the database query fails or if task data is invalid
Sourcepub async fn get_inbox(&self, limit: Option<usize>) -> ThingsResult<Vec<Task>>
pub async fn get_inbox(&self, limit: Option<usize>) -> ThingsResult<Vec<Task>>
Get inbox tasks (incomplete tasks without project)
§Errors
Returns an error if the database query fails or if task data is invalid
Sourcepub async fn get_projects(
&self,
limit: Option<usize>,
) -> ThingsResult<Vec<Project>>
pub async fn get_projects( &self, limit: Option<usize>, ) -> ThingsResult<Vec<Project>>
Get all projects (alias for get_all_projects
for compatibility)
§Errors
Returns an error if the database query fails or if project data is invalid
Trait Implementations§
Source§impl Clone for ThingsDatabase
impl Clone for ThingsDatabase
Source§fn clone(&self) -> ThingsDatabase
fn clone(&self) -> ThingsDatabase
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for ThingsDatabase
impl !RefUnwindSafe for ThingsDatabase
impl Send for ThingsDatabase
impl Sync for ThingsDatabase
impl Unpin for ThingsDatabase
impl !UnwindSafe for ThingsDatabase
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more