WIP termial implementation. need some way of getting the currently valid workspace ID
This commit is contained in:
parent
a8ed95e1dc
commit
e659823e6c
6 changed files with 84 additions and 55 deletions
|
@ -1,3 +1,5 @@
|
|||
pub use anyhow;
|
||||
|
||||
pub mod bindable;
|
||||
pub mod connection;
|
||||
pub mod domain;
|
||||
|
|
|
@ -52,3 +52,57 @@ impl Connection {
|
|||
Ok(move |bindings| statement.with_bindings(bindings)?.maybe_row::<C>())
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! exec_method {
|
||||
($id:ident(): $sql:literal) => {
|
||||
pub fn $id(&self) -> $crate::anyhow::Result<()> {
|
||||
iife!({
|
||||
self.exec($sql)?()
|
||||
})
|
||||
}
|
||||
};
|
||||
($id:ident($($arg:ident: $arg_type:ty),+): $sql:literal) => {
|
||||
pub fn $id(&self, $($arg: $arg_type),+) -> $crate::anyhow::Result<()> {
|
||||
iife!({
|
||||
self.exec_bound::<($($arg_type),+)>($sql)?(($($arg),+))
|
||||
})
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! select_method {
|
||||
($id:ident() -> $return_type:ty: $sql:literal) => {
|
||||
pub fn $id(&self) -> $crate::anyhow::Result<Vec<$return_type>> {
|
||||
iife!({
|
||||
self.select::<$return_type>($sql)?(())
|
||||
})
|
||||
}
|
||||
};
|
||||
($id:ident($($arg:ident: $arg_type:ty),+) -> $return_type:ty: $sql:literal) => {
|
||||
pub fn $id(&self, $($arg: $arg_type),+) -> $crate::anyhow::Result<Vec<$return_type>> {
|
||||
iife!({
|
||||
self.exec_bound::<($($arg_type),+), $return_type>($sql)?(($($arg),+))
|
||||
})
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! select_row_method {
|
||||
($id:ident() -> $return_type:ty: $sql:literal) => {
|
||||
pub fn $id(&self) -> $crate::anyhow::Result<Option<$return_type>> {
|
||||
iife!({
|
||||
self.select_row::<$return_type>($sql)?(())
|
||||
})
|
||||
}
|
||||
};
|
||||
($id:ident($($arg:ident: $arg_type:ty),+) -> $return_type:ty: $sql:literal) => {
|
||||
pub fn $id(&self, $($arg: $arg_type),+) -> $crate::anyhow::Result<Option<$return_type>> {
|
||||
iife!({
|
||||
self.select_row_bound::<($($arg_type),+), $return_type>($sql)?(($($arg),+))
|
||||
})
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue