pub struct SqliteRawEngine { /* private fields */ }Expand description
Legacy SQLite query engine with JSON results.
Implementations§
Source§impl SqliteRawEngine
impl SqliteRawEngine
Sourcepub fn new(pool: SqlitePool) -> Self
pub fn new(pool: SqlitePool) -> Self
Create a new SQLite engine with the given pool.
Sourcepub fn pool(&self) -> &SqlitePool
pub fn pool(&self) -> &SqlitePool
Get a reference to the connection pool.
Sourcepub async fn query_many(
&self,
table: &str,
columns: &[String],
filters: &HashMap<String, FilterValue>,
sort: &[(String, SortOrder)],
limit: Option<u64>,
offset: Option<u64>,
) -> Result<Vec<SqliteJsonRow>, SqliteError>
pub async fn query_many( &self, table: &str, columns: &[String], filters: &HashMap<String, FilterValue>, sort: &[(String, SortOrder)], limit: Option<u64>, offset: Option<u64>, ) -> Result<Vec<SqliteJsonRow>, SqliteError>
Execute a query and return multiple results.
Sourcepub async fn query_one(
&self,
table: &str,
columns: &[String],
filters: &HashMap<String, FilterValue>,
) -> Result<SqliteJsonRow, SqliteError>
pub async fn query_one( &self, table: &str, columns: &[String], filters: &HashMap<String, FilterValue>, ) -> Result<SqliteJsonRow, SqliteError>
Execute a query and return a single result.
Sourcepub async fn query_optional(
&self,
table: &str,
columns: &[String],
filters: &HashMap<String, FilterValue>,
) -> Result<Option<SqliteJsonRow>, SqliteError>
pub async fn query_optional( &self, table: &str, columns: &[String], filters: &HashMap<String, FilterValue>, ) -> Result<Option<SqliteJsonRow>, SqliteError>
Execute a query and return an optional result.
Sourcepub async fn execute_insert(
&self,
table: &str,
data: &HashMap<String, FilterValue>,
) -> Result<SqliteJsonRow, SqliteError>
pub async fn execute_insert( &self, table: &str, data: &HashMap<String, FilterValue>, ) -> Result<SqliteJsonRow, SqliteError>
Execute an INSERT and return the result.
The returned row echoes the submitted values plus the rowid of the new
row under the id key (skipped if an id value was submitted); it does
not re-read the persisted row, so database-generated defaults and
trigger effects are not reflected.
Sourcepub async fn execute_update(
&self,
table: &str,
data: &HashMap<String, FilterValue>,
filters: &HashMap<String, FilterValue>,
) -> Result<u64, SqliteError>
pub async fn execute_update( &self, table: &str, data: &HashMap<String, FilterValue>, filters: &HashMap<String, FilterValue>, ) -> Result<u64, SqliteError>
Execute an UPDATE and return the number of affected rows.
Sourcepub async fn execute_delete(
&self,
table: &str,
filters: &HashMap<String, FilterValue>,
) -> Result<u64, SqliteError>
pub async fn execute_delete( &self, table: &str, filters: &HashMap<String, FilterValue>, ) -> Result<u64, SqliteError>
Execute a DELETE and return the number of affected rows.
Sourcepub async fn execute_raw(
&self,
sql: &str,
params: &[FilterValue],
) -> Result<Vec<SqliteJsonRow>, SqliteError>
pub async fn execute_raw( &self, sql: &str, params: &[FilterValue], ) -> Result<Vec<SqliteJsonRow>, SqliteError>
Execute raw SQL and return results.
Sourcepub async fn raw_sql(&self, sql: Sql) -> Result<Vec<SqliteJsonRow>, SqliteError>
pub async fn raw_sql(&self, sql: Sql) -> Result<Vec<SqliteJsonRow>, SqliteError>
Sourcepub async fn raw_sql_query(
&self,
sql: &str,
params: &[FilterValue],
) -> Result<Vec<SqliteJsonRow>, SqliteError>
pub async fn raw_sql_query( &self, sql: &str, params: &[FilterValue], ) -> Result<Vec<SqliteJsonRow>, SqliteError>
Sourcepub async fn raw_sql_execute(
&self,
sql: &str,
params: &[FilterValue],
) -> Result<u64, SqliteError>
pub async fn raw_sql_execute( &self, sql: &str, params: &[FilterValue], ) -> Result<u64, SqliteError>
Execute a raw SQL statement and return the number of affected rows.
Use this for INSERT, UPDATE, DELETE, or other statements that don’t return rows.
§Example
let affected = engine.raw_sql_execute(
"UPDATE users SET last_login = datetime('now') WHERE id = ?",
&[FilterValue::Int(user_id)]
).await?;
println!("Updated {} rows", affected);Sourcepub async fn raw_sql_first(
&self,
sql: &str,
params: &[FilterValue],
) -> Result<SqliteJsonRow, SqliteError>
pub async fn raw_sql_first( &self, sql: &str, params: &[FilterValue], ) -> Result<SqliteJsonRow, SqliteError>
Sourcepub async fn raw_sql_optional(
&self,
sql: &str,
params: &[FilterValue],
) -> Result<Option<SqliteJsonRow>, SqliteError>
pub async fn raw_sql_optional( &self, sql: &str, params: &[FilterValue], ) -> Result<Option<SqliteJsonRow>, SqliteError>
Sourcepub async fn raw_sql_scalar<T>(
&self,
sql: &str,
params: &[FilterValue],
) -> Result<T, SqliteError>where
T: for<'a> Deserialize<'a>,
pub async fn raw_sql_scalar<T>(
&self,
sql: &str,
params: &[FilterValue],
) -> Result<T, SqliteError>where
T: for<'a> Deserialize<'a>,
Sourcepub async fn raw_sql_batch(&self, sql: &str) -> Result<(), SqliteError>
pub async fn raw_sql_batch(&self, sql: &str) -> Result<(), SqliteError>
Sourcepub async fn count(
&self,
table: &str,
filters: &HashMap<String, FilterValue>,
) -> Result<u64, SqliteError>
pub async fn count( &self, table: &str, filters: &HashMap<String, FilterValue>, ) -> Result<u64, SqliteError>
Count rows matching the filter.
Trait Implementations§
Source§impl Clone for SqliteRawEngine
impl Clone for SqliteRawEngine
Source§fn clone(&self) -> SqliteRawEngine
fn clone(&self) -> SqliteRawEngine
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more