#[macro_export]
macro_rules! match_row {
($res:ident, $type:ty) => {
match $res.single_row_typed::<$type>() {
Ok(data) => Ok(Some(data)),
Err(err) => {
use scylla::transport::query_result::SingleRowTypedError;
match err {
SingleRowTypedError::BadNumberOfRows(_) => Ok(None),
_ => {
tracing::error!("err: {:?}", err);
Err(scyllax::prelude::ScyllaxError::SingleRowTyped(err))
}
}
}
}
};
}
#[macro_export]
macro_rules! match_rows {
($res:ident, $type:ty) => {
match $res.rows_typed::<$type>() {
Ok(xs) => Ok(xs.filter_map(|x| x.ok()).collect::<Vec<$type>>()),
Err(e) => {
tracing::error!("err: {:?}", e);
Ok(vec![])
}
}
};
}