cat_gateway/db/event/signed_docs/
doc_ref.rs1use crate::db::event::common::eq_or_ranged_uuid::EqOrRangedUuid;
4
5#[derive(Clone, Debug)]
7pub(crate) struct DocumentRef {
8 pub(crate) id: Option<EqOrRangedUuid>,
10 pub(crate) ver: Option<EqOrRangedUuid>,
12}
13
14impl DocumentRef {
15 pub(crate) fn conditional_stmt(&self, table_field: &str) -> String {
17 let mut stmt = "TRUE".to_string();
18 if let Some(id) = &self.id {
19 stmt.push_str(&format!(
20 " AND {}",
21 id.conditional_stmt(&format!("({table_field}->>'id')::uuid"))
22 ));
23 }
24 if let Some(ver) = &self.ver {
25 stmt.push_str(&format!(
26 " AND {}",
27 ver.conditional_stmt(&format!("({table_field}->>'ver')::uuid"))
28 ));
29 }
30 stmt
31 }
32}