macro_rules! db_query_all {
    // no params
    (fn $name:ident() -> Vec<$ret:ty>, $query:expr) => {
        pub fn $name(&mut self) -> Result<Vec<$ret>, DatabaseError> {
            self.query_all(&$query, [])
        }
    };
    // with params
    (fn $name:ident($($param:ident : $ptype:ty),*) -> Vec<$ret:ty>, $query:expr) => {
        pub fn $name(&mut self, $($param: $ptype),+) -> Result<Vec<$ret>, DatabaseError> {
            self.query_all(&$query, params![$($param),*])
        }
    };
}

macro_rules! db_query_opt {
    (fn $name:ident($($param:ident : $ptype:ty),+) -> Option<$ret:ty>, $query:expr) => {
        pub fn $name(&mut self, $($param: $ptype),+) -> Result<Option<$ret>, DatabaseError> {
            self.query_opt(&$query, params![$($param),+])
        }
    };
}

macro_rules! db_exec {
    // no params
    (fn $name:ident(), $query:expr) => {
        pub fn $name(&mut self) -> Result<(), DatabaseError> {
            self.exec_cmd(&$query, [])?;
            Ok(())
        }
    };
    // with params
    (fn $name:ident($($param:ident: $ptype:ty),+), $query:expr) => {
        pub fn $name(&mut self, $($param: $ptype),+) -> Result<(), DatabaseError> {
            self.exec_cmd(&$query, params![$($param),+])?;
            Ok(())
        }
    };
}
