pub struct Glue {
pub primary: String,
pub tempdb: TempDB,
/* private fields */
}
Expand description
§Glue
Glue is the interface for interacting with MultiSQL; a Glue instance comprises any number of stores, each with their own identifier. Once built, one will typically interact with Glue via queries.
There is a number of ways to deposit queries however, depending on the desired output:
Glue::execute()
– Might be considered the most generic. Replies with a Result<Payload> (payload being the response from any type of query).Glue::execute_many()
– Same asexecute()
but will find any number of seperate queries in given text and provide a Vec in response.Glue::select_as_string()
– Provides data, only forSELECT
queries, as Strings (rather than Values).- [
Glue::select_as_json()
] – Provides data, only forSELECT
queries, as one big String; generally useful for webby interactions.
Fields§
§primary: String
§tempdb: TempDB
Implementations§
Source§impl Glue
impl Glue
pub async fn ast_delete( &mut self, table_name: &ObjectName, selection: &Option<Expr>, ) -> Result<Payload>
Source§impl Glue
impl Glue
pub async fn ast_insert( &mut self, table_name: &ObjectName, columns: &[Ident], source: &Query, expect_data: bool, ) -> Result<Payload>
pub async fn true_insert( &mut self, database: &Option<String>, table: &str, columns: &[&str], rows: Vec<Vec<Value>>, labels: Option<Vec<String>>, expect_data: bool, ) -> Result<Payload>
pub async fn insert_data( &mut self, database: &Option<String>, table_name: &str, rows: Vec<Row>, ) -> Result<()>
Source§impl Glue
impl Glue
pub async fn ast_update( &mut self, table: &TableWithJoins, selection: &Option<Expr>, assignments: &[Assignment], ) -> Result<Payload>
Source§impl Glue
impl Glue
pub async fn ast_alter_table( &mut self, name: &ObjectName, operation: &AlterTableOperation, ) -> Result<()>
Source§impl Glue
impl Glue
pub async fn ast_drop( &mut self, object_type: &ObjectType, names: &[ObjectName], if_exists: bool, ) -> Result<()>
Source§impl Glue
impl Glue
pub async fn ast_truncate(&mut self, table_name: &ObjectName) -> Result<()>
Source§impl Glue
impl Glue
pub async fn ast_create_index( &mut self, table: &ObjectName, name: &ObjectName, columns: &[OrderByExpr], unique: bool, if_not_exists: bool, ) -> Result<()>
Source§impl Glue
impl Glue
pub async fn ast_create_view( &mut self, name: &ObjectName, query: &Box<Query>, or_replace: bool, ) -> Result<()>
Source§impl Glue
impl Glue
pub async fn get_columns( &self, table: ComplexTableName, ) -> Result<Vec<ColumnInfo>>
pub fn get_view_columns<'life0, 'life1, 'life_self, 'async_recursion>(
&'life_self self,
view_name: &'life0 str,
database: &'life1 Option<String>,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<String>>>> + 'async_recursion>>where
'life0: 'async_recursion,
'life1: 'async_recursion,
'life_self: 'async_recursion,
Source§impl Glue
impl Glue
pub fn get_rows<'life0, 'life1, 'life2, 'life_self, 'async_recursion>(
&'life_self self,
table: &'life0 str,
database: &'life1 Option<String>,
index_filter: &'life2 Option<IndexFilter>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<Value>>>> + 'async_recursion>>where
'life0: 'async_recursion,
'life1: 'async_recursion,
'life2: 'async_recursion,
'life_self: 'async_recursion,
pub async fn get_view_rows( &self, view_name: &str, database: &Option<String>, ) -> Result<Option<Vec<Vec<Value>>>>
pub async fn get_table_rows( &self, table: &str, database: &Option<String>, index_filter: &Option<IndexFilter>, ) -> Result<Vec<Vec<Value>>>
Source§impl Glue
impl Glue
pub async fn set_variable( &mut self, variable: &Ident, value: &[SetVariableValue], ) -> Result<()>
Source§impl Glue
impl Glue
pub fn get_database( &self, db_ref: &Option<String>, ) -> Result<MutexGuard<'_, Box<DatabaseInner>>>
pub fn get_mut_database( &mut self, db_ref: &Option<String>, ) -> Result<&mut Box<DatabaseInner>>
pub fn get_database_list(&self) -> Vec<&String>
Source§impl Glue
§Select (SELECT
)
impl Glue
§Select (SELECT
)
Sourcepub fn select_json(&mut self, query: &str) -> Result<JSONValue>
pub fn select_json(&mut self, query: &str) -> Result<JSONValue>
Only for SELECT
queries.
Output is one big serde_json::Value, wrapped in a Result.
Generally useful for webby interactions.
Sourcepub fn select_as_string(&mut self, query: &str) -> Result<Vec<Vec<String>>>
pub fn select_as_string(&mut self, query: &str) -> Result<Vec<Vec<String>>>
Only for SELECT
queries.
Sourcepub fn select_as_csv(&mut self, query: &str) -> Result<String>
pub fn select_as_csv(&mut self, query: &str) -> Result<String>
Only for SELECT
queries.
Source§impl Glue
§Creation of new interfaces
impl Glue
§Creation of new interfaces
Sourcepub fn new_multi_glue(glues: Vec<Glue>) -> Self
pub fn new_multi_glue(glues: Vec<Glue>) -> Self
Merges existing Glue instances
Sourcepub fn extend_many_glues(&mut self, glues: Vec<Glue>)
pub fn extend_many_glues(&mut self, glues: Vec<Glue>)
Merge existing Glue with Vec of other Glues For example:
use multisql::{SledDatabase, Database, Glue};
let storage = SledDatabase::new("data/example_location/example")
.map(Database::new_sled)
.expect("Database Creation Failed");
let mut glue = Glue::new(String::from("main"), storage);
glue.execute_many("
DROP TABLE IF EXISTS test;
CREATE TABLE test (id INTEGER);
INSERT INTO test VALUES (1),(2);
SELECT * FROM test WHERE id > 1;
");
let other_storage = SledDatabase::new("data/example_location/example_other")
.map(Database::new_sled)
.expect("Database Creation Failed");
let mut other_glue = Glue::new(String::from("other"), other_storage);
glue.extend_many_glues(vec![other_glue]);
pub fn extend_glue(&mut self, glue: Glue)
Sourcepub fn try_extend_from_path(
&mut self,
database_name: String,
database_path: String,
) -> Result<bool>
pub fn try_extend_from_path( &mut self, database_name: String, database_path: String, ) -> Result<bool>
Source§impl Glue
impl Glue
pub fn into_connections(self) -> Vec<(String, Connection)>
Auto Trait Implementations§
impl Freeze for Glue
impl RefUnwindSafe for Glue
impl !Send for Glue
impl !Sync for Glue
impl Unpin for Glue
impl UnwindSafe for Glue
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
Source§impl<Core, Value> ConvertFrom<Value> for Core
impl<Core, Value> ConvertFrom<Value> for Core
fn convert_from(value: Value) -> Result<Core, Error>
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>
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 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>
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