1use crate::expr::TableRef;
2use crate::predicate::Predicate;
3use sql_orm_core::Entity;
4
5#[derive(Debug, Clone, PartialEq)]
6pub struct DeleteQuery {
7 pub from: TableRef,
8 pub predicate: Option<Predicate>,
9}
10
11impl DeleteQuery {
12 pub fn from_entity<E: Entity>() -> Self {
13 Self {
14 from: TableRef::for_entity::<E>(),
15 predicate: None,
16 }
17 }
18
19 pub fn filter(mut self, predicate: Predicate) -> Self {
20 self.predicate = Some(match self.predicate.take() {
21 Some(existing) => Predicate::and(vec![existing, predicate]),
22 None => predicate,
23 });
24 self
25 }
26}