upend/db/src/macros.rs

28 lines
971 B
Rust
Raw Normal View History

#[macro_export]
macro_rules! upend_insert_val {
($db_connection:expr, $entity:expr, $attribute:expr, $value:expr) => {{
2022-02-02 17:13:23 +01:00
$db_connection.insert_entry(Entry {
entity: $entity.clone(),
attribute: $attribute.parse().unwrap(),
2023-06-25 15:29:52 +02:00
value: upend_base::entry::EntryValue::String(String::from($value)),
provenance: "SYSTEM INIT".to_string(),
user: None,
timestamp: chrono::Utc::now().naive_utc(),
2022-02-02 17:13:23 +01:00
})
}};
}
#[macro_export]
macro_rules! upend_insert_addr {
($db_connection:expr, $entity:expr, $attribute:expr, $addr:expr) => {{
2022-02-02 17:13:23 +01:00
$db_connection.insert_entry(Entry {
entity: $entity.clone(),
attribute: $attribute.parse().unwrap(),
2023-06-25 15:29:52 +02:00
value: upend_base::entry::EntryValue::Address($addr.clone()),
provenance: "SYSTEM INIT".to_string(),
user: None,
timestamp: chrono::Utc::now().naive_utc(),
2022-02-02 17:13:23 +01:00
})
}};
}