mithril_aggregator/database/query/certificate/
delete_certificate.rs1use sqlite::Value;
2
3use mithril_persistence::sqlite::{Query, SourceAlias, SqLiteEntity, WhereCondition};
4
5use crate::database::record::CertificateRecord;
6
7pub struct DeleteCertificateQuery {
9 condition: WhereCondition,
10}
11
12impl Query for DeleteCertificateQuery {
13 type Entity = CertificateRecord;
14
15 fn filters(&self) -> WhereCondition {
16 self.condition.clone()
17 }
18
19 fn get_definition(&self, condition: &str) -> String {
20 let projection = Self::Entity::get_projection()
23 .expand(SourceAlias::new(&[("{:certificate:}", "certificate")]));
24
25 format!("delete from certificate where {condition} returning {projection}")
26 }
27}
28
29impl DeleteCertificateQuery {
30 pub fn by_ids(ids: &[&str]) -> Self {
32 let ids_values = ids.iter().map(|id| Value::String(id.to_string())).collect();
33
34 Self {
35 condition: WhereCondition::where_in("certificate_id", ids_values),
36 }
37 }
38}