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 Batch,
19}
20
21#[derive(Debug, Clone)]
23pub enum QueryOrder {
24 Asc,
26 Desc,
28}
29
30impl ToSqlite for QueryOrder {
31 fn to_sqlite(&self) -> String {
32 match self {
33 QueryOrder::Asc => String::from("ASC"),
34 QueryOrder::Desc => String::from("DESC"),
35 }
36 }
37}
38
39#[derive(Debug, Clone, Default)]
41pub enum QueryCondition {
42 #[default]
44 Eq,
45 Ne,
47 Like,
49 Gt,
51 Lt,
53 Gte,
55 Lte,
57}
58
59impl ToSqlite for QueryCondition {
60 fn to_sqlite(&self) -> String {
61 match self {
62 QueryCondition::Eq => String::from("="),
63 QueryCondition::Ne => String::from("!="),
64 QueryCondition::Like => String::from("LIKE"),
65 QueryCondition::Gt => String::from(">"),
66 QueryCondition::Lt => String::from("<"),
67 QueryCondition::Gte => String::from(">="),
68 QueryCondition::Lte => String::from("<="),
69 }
70 }
71}
72
73#[derive(Debug, Clone, Default)]
75pub enum WhereCondition {
76 #[default]
78 And,
79 Or,
81}
82
83impl WhereCondition {
84 pub fn all() -> Vec<String> {
86 vec![
87 WhereCondition::And.to_sqlite(),
88 WhereCondition::Or.to_sqlite(),
89 ]
90 }
91}
92
93impl ToSqlite for WhereCondition {
94 fn to_sqlite(&self) -> String {
95 match self {
96 WhereCondition::And => String::from("AND"),
97 WhereCondition::Or => String::from("OR"),
98 }
99 }
100}