pub trait Db: Send + Sync {
// Required methods
fn dialect(&self) -> Dialect;
fn all<'a>(
&'a self,
sql: &'a str,
params: Vec<Param>,
) -> BoxFuture<'a, Result<Vec<Row>, DbError>>;
fn run<'a>(
&'a self,
sql: &'a str,
params: Vec<Param>,
) -> BoxFuture<'a, Result<u64, DbError>>;
fn hold(&self, kind: Hold) -> BoxFuture<'_, Result<Arc<dyn Db>, DbError>>;
// Provided methods
fn finish(&self, _ok: bool) -> BoxFuture<'_, Result<(), DbError>> { ... }
fn metered(&self) -> bool { ... }
fn close(&self) -> BoxFuture<'_, ()> { ... }
fn prefix(&self) -> Option<&str> { ... }
}Expand description
The little a store needs from a database driver. SQL uses ? placeholders and “double quotes”
around a name that is a keyword somewhere; a driver numbers the placeholders, or fills them in and
quotes names its own way, as the TypeScript drivers do.
Required Methods§
Sourcefn all<'a>(
&'a self,
sql: &'a str,
params: Vec<Param>,
) -> BoxFuture<'a, Result<Vec<Row>, DbError>>
fn all<'a>( &'a self, sql: &'a str, params: Vec<Param>, ) -> BoxFuture<'a, Result<Vec<Row>, DbError>>
Runs a query and gives its rows.
Provided Methods§
Sourcefn finish(&self, _ok: bool) -> BoxFuture<'_, Result<(), DbError>>
fn finish(&self, _ok: bool) -> BoxFuture<'_, Result<(), DbError>>
Ends what hold began: commits a transaction (ok) or rolls it back, or lets go of a lock.
A connection that was not held answers Ok.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".