ThingsDatabase

Struct ThingsDatabase 

Source
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

Source

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

Source

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

Source

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

Source

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

Source

pub fn pool(&self) -> &SqlitePool

Get the underlying connection pool

Source

pub async fn is_connected(&self) -> bool

Check if the database is connected

Source

pub async fn get_pool_health(&self) -> ThingsResult<PoolHealthStatus>

Get connection pool health status

§Errors

Returns an error if the health check fails

Source

pub async fn get_pool_metrics(&self) -> ThingsResult<PoolMetrics>

Get detailed connection pool metrics

§Errors

Returns an error if the metrics collection fails

Source

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

Source

pub async fn get_stats(&self) -> ThingsResult<DatabaseStats>

Get database statistics

§Errors

Returns an error if the database query fails

Source

pub async fn get_all_tasks(&self) -> ThingsResult<Vec<Task>>

Get all tasks

§Errors

Returns an error if the database query fails or if task data is invalid

Source

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

Source

pub async fn get_all_areas(&self) -> ThingsResult<Vec<Area>>

Get all areas

§Errors

Returns an error if the database query fails or if area data is invalid

Source

pub async fn get_tasks_by_status( &self, status: TaskStatus, ) -> ThingsResult<Vec<Task>>

Get tasks by status

§Errors

Returns an error if the database query fails or if task data is invalid

Source

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

Source

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

Source

pub async fn get_today(&self, limit: Option<usize>) -> ThingsResult<Vec<Task>>

Get today’s tasks (incomplete tasks due today or started today)

§Errors

Returns an error if the database query fails or if task data is invalid

§Panics

Panics if the current date cannot be converted to a valid time with hours, minutes, and seconds

Source

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

Source

pub async fn get_areas(&self) -> ThingsResult<Vec<Area>>

Get all areas (alias for get_all_areas for compatibility)

§Errors

Returns an error if the database query fails or if area data is invalid

Trait Implementations§

Source§

impl Clone for ThingsDatabase

Source§

fn clone(&self) -> ThingsDatabase

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ThingsDatabase

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,