mithril_aggregator/database/query/immutable_file_digest/
delete_immutable_file_digest.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use mithril_persistence::sqlite::{Query, WhereCondition};

use crate::database::record::ImmutableFileDigestRecord;

/// Query to delete [ImmutableFileDigestRecord] from the sqlite database
pub struct DeleteImmutableFileDigestQuery {
    condition: WhereCondition,
}

impl DeleteImmutableFileDigestQuery {
    pub fn all() -> Self {
        Self {
            condition: WhereCondition::default(),
        }
    }
}

impl Query for DeleteImmutableFileDigestQuery {
    type Entity = ImmutableFileDigestRecord;

    fn filters(&self) -> WhereCondition {
        self.condition.clone()
    }

    fn get_definition(&self, condition: &str) -> String {
        let projection = Self::Entity::expand_projection("immutable_file_digest");

        format!("delete from immutable_file_digest where {condition} returning {projection}")
    }
}