geekorm_core/builder/
models.rs1use crate::ToSqlite;
2
3#[derive(Debug, Clone, Default, PartialEq, Eq)]
5pub enum QueryType {
6 Create,
8 #[default]
10 Select,
11 Insert,
13 Update,
15 Delete,
17}
18
19#[derive(Debug, Clone)]
21pub enum QueryOrder {
22 Asc,
24 Desc,
26}
27
28impl ToSqlite for QueryOrder {
29 fn to_sqlite(&self) -> String {
30 match self {
31 QueryOrder::Asc => String::from("ASC"),
32 QueryOrder::Desc => String::from("DESC"),
33 }
34 }
35}
36
37#[derive(Debug, Clone, Default)]
39pub enum QueryCondition {
40 #[default]
42 Eq,
43 Ne,
45 Like,
47 Gt,
49 Lt,
51 Gte,
53 Lte,
55}
56
57impl ToSqlite for QueryCondition {
58 fn to_sqlite(&self) -> String {
59 match self {
60 QueryCondition::Eq => String::from("="),
61 QueryCondition::Ne => String::from("!="),
62 QueryCondition::Like => String::from("LIKE"),
63 QueryCondition::Gt => String::from(">"),
64 QueryCondition::Lt => String::from("<"),
65 QueryCondition::Gte => String::from(">="),
66 QueryCondition::Lte => String::from("<="),
67 }
68 }
69}
70
71#[derive(Debug, Clone, Default)]
73pub enum WhereCondition {
74 #[default]
76 And,
77 Or,
79}
80
81impl WhereCondition {
82 pub fn all() -> Vec<String> {
84 vec![
85 WhereCondition::And.to_sqlite(),
86 WhereCondition::Or.to_sqlite(),
87 ]
88 }
89}
90
91impl ToSqlite for WhereCondition {
92 fn to_sqlite(&self) -> String {
93 match self {
94 WhereCondition::And => String::from("AND"),
95 WhereCondition::Or => String::from("OR"),
96 }
97 }
98}