pub struct DB {}Expand description
A struct that represents a database.
Implementations§
Source§impl DB
impl DB
Sourcepub fn exist_schema(table_name: &str, schema: &str) -> bool
pub fn exist_schema(table_name: &str, schema: &str) -> bool
Sourcepub fn transaction(query: DBQuery) -> bool
pub fn transaction(query: DBQuery) -> bool
Sourcepub fn transaction_async(query: DBQuery, callback: Box<dyn FnMut(bool)>)
pub fn transaction_async(query: DBQuery, callback: Box<dyn FnMut(bool)>)
Executes a list of SQL statements as a single transaction asynchronously.
§Arguments
sqls- A list of SQL statements to execute.callback- A callback function that is invoked when the transaction is executed, receiving the result of the transaction.
§Returns
bool-trueif the transaction was successful,falseotherwise.
Sourcepub fn exec_with_records(sql: &str, values: DBParams) -> i32
pub fn exec_with_records(sql: &str, values: DBParams) -> i32
Sourcepub fn query_with_params_async(
sql: &str,
params: &Array,
with_columns: bool,
callback: Box<dyn FnMut(DBRecord)>,
)
pub fn query_with_params_async( sql: &str, params: &Array, with_columns: bool, callback: Box<dyn FnMut(DBRecord)>, )
Executes an SQL query asynchronously and returns the results as a list of rows.
§Arguments
sql- The SQL statement to execute.params- Optional. A list of values to substitute into the SQL statement.with_column- Optional. Whether to include column names in the result. Default isfalse.callback- A callback function that is invoked when the query is executed, receiving the results as a list of rows.
Sourcepub fn insert_async(
table_name: &str,
values: DBParams,
callback: Box<dyn FnMut(bool)>,
)
pub fn insert_async( table_name: &str, values: DBParams, callback: Box<dyn FnMut(bool)>, )
Inserts a row of data into a table within a transaction asynchronously.
§Arguments
table_name- The name of the table to insert into.values- The values to insert into the table.callback- A callback function that is invoked when the insertion is executed, receiving the result of the insertion.
Sourcepub fn exec_async(sql: &str, values: DBParams, callback: Box<dyn FnMut(i64)>)
pub fn exec_async(sql: &str, values: DBParams, callback: Box<dyn FnMut(i64)>)
Executes an SQL statement with a list of values within a transaction asynchronously and returns the number of rows affected.
§Arguments
sql- The SQL statement to execute.values- A list of values to substitute into the SQL statement.callback- A callback function that is invoked when the statement is executed, recieving the number of rows affected.
Auto Trait Implementations§
impl Freeze for DB
impl RefUnwindSafe for DB
impl Send for DB
impl Sync for DB
impl Unpin for DB
impl UnwindSafe for DB
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
Mutably borrows from an owned value. Read more