cat_gateway/db/event/signed_docs/
doc_ref.rsuse crate::db::event::common::eq_or_ranged_uuid::EqOrRangedUuid;
#[derive(Clone, Debug)]
pub(crate) struct DocumentRef {
pub(crate) id: Option<EqOrRangedUuid>,
pub(crate) ver: Option<EqOrRangedUuid>,
}
impl DocumentRef {
pub(crate) fn conditional_stmt(&self, table_field: &str) -> String {
let mut stmt = "TRUE".to_string();
if let Some(id) = &self.id {
stmt.push_str(&format!(
" AND {}",
id.conditional_stmt(&format!("({table_field}->>'id')::uuid"))
));
}
if let Some(ver) = &self.ver {
stmt.push_str(&format!(
" AND {}",
ver.conditional_stmt(&format!("({table_field}->>'ver')::uuid"))
));
}
stmt
}
}