sqlorm_core/sb/
mod.rs

1use crate::{Condition, TableInfo, selectable::Selectable};
2
3pub struct SB<T> {
4    /// Base table information and selected columns.
5    pub base: TableInfo,
6    /// Fields update
7    pub fields: Option<Vec<&'static str>>,
8    /// WHERE clause conditions combined with AND.
9    pub filters: Vec<Condition>,
10    /// The entity to operate on
11    pub entity: T,
12}
13impl<T> SB<T> {
14    pub fn new(base: TableInfo, entity: T) -> SB<T> {
15        SB {
16            base,
17            filters: Vec::new(),
18            fields: None,
19            entity,
20        }
21    }
22
23    pub fn columns(mut self, fields: impl Selectable) -> Self {
24        self.fields = Some(fields.collect());
25        self
26    }
27
28    pub fn filter(mut self, cond: Condition) -> Self {
29        self.filters.push(cond);
30        self
31    }
32}