Struct ockam_node::storage::database::SqlxDatabase
source · pub struct SqlxDatabase {
pub pool: Arc<SqlitePool>,
pub node_name: Option<String>,
}Expand description
The SqlxDatabase struct is used to create a database:
- at a given path
- with a given schema / or migrations applied to an existing schema
We use sqlx as our primary interface for interacting with the database The database driver is currently Sqlite
Fields§
§pool: Arc<SqlitePool>Pool of connections to the database
node_name: Option<String>Node name to isolate data between nodes where needed
Implementations§
source§impl SqlxDatabase
impl SqlxDatabase
sourcepub async fn create(path: impl AsRef<Path>) -> Result<Self>
pub async fn create(path: impl AsRef<Path>) -> Result<Self>
Constructor for a database persisted on disk
sourcepub async fn create_with_migration(
path: impl AsRef<Path>,
migration_set: impl MigrationSet
) -> Result<Self>
pub async fn create_with_migration( path: impl AsRef<Path>, migration_set: impl MigrationSet ) -> Result<Self>
Constructor for a database persisted on disk, with a specific schema / migration
sourcepub async fn create_no_migration(path: impl AsRef<Path>) -> Result<Self>
pub async fn create_no_migration(path: impl AsRef<Path>) -> Result<Self>
Constructor for a database persisted on disk without migration
sourcepub async fn create_with_node_name(
path: impl AsRef<Path>,
node_name: &str
) -> Result<Self>
pub async fn create_with_node_name( path: impl AsRef<Path>, node_name: &str ) -> Result<Self>
Constructor for a database persisted on disk, passing a node name to isolate data between nodes where needed
sourcepub async fn in_memory(usage: &str) -> Result<Self>
pub async fn in_memory(usage: &str) -> Result<Self>
Create a nodes database in memory
=> this database is deleted on an ockam reset command! (contrary to the application database below)
sourcepub async fn application_in_memory(usage: &str) -> Result<Self>
pub async fn application_in_memory(usage: &str) -> Result<Self>
Create an application database in memory
The application database which contains the application configurations
=> this database is NOT deleted on an ockam reset command!
sourcepub async fn in_memory_with_migration(
usage: &str,
migration_set: impl MigrationSet
) -> Result<Self>
pub async fn in_memory_with_migration( usage: &str, migration_set: impl MigrationSet ) -> Result<Self>
Create an in-memory database with a specific migration
sourcepub fn set_node_name(&mut self, node_name: &str)
pub fn set_node_name(&mut self, node_name: &str)
Set the node name
sourcepub fn map_sql_err(err: Error) -> Error
pub fn map_sql_err(err: Error) -> Error
Map a sqlx error into an ockam error
sourcepub fn map_decode_err(err: Error) -> Error
pub fn map_decode_err(err: Error) -> Error
Map a minicbor decode error into an ockam error
Trait Implementations§
source§impl Clone for SqlxDatabase
impl Clone for SqlxDatabase
source§fn clone(&self) -> SqlxDatabase
fn clone(&self) -> SqlxDatabase
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for SqlxDatabase
impl Debug for SqlxDatabase
Auto Trait Implementations§
impl Freeze for SqlxDatabase
impl !RefUnwindSafe for SqlxDatabase
impl Send for SqlxDatabase
impl Sync for SqlxDatabase
impl Unpin for SqlxDatabase
impl !UnwindSafe for SqlxDatabase
Blanket Implementations§
source§impl<D> AsyncTryClone for D
impl<D> AsyncTryClone for D
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> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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