elif_orm/query/
ordering.rs1use serde_json::Value;
4use super::builder::QueryBuilder;
5use super::types::*;
6
7impl<M> QueryBuilder<M> {
8 pub fn order_by(mut self, column: &str) -> Self {
10 self.order_by.push((column.to_string(), OrderDirection::Asc));
11 self
12 }
13
14 pub fn order_by_desc(mut self, column: &str) -> Self {
16 self.order_by.push((column.to_string(), OrderDirection::Desc));
17 self
18 }
19
20 pub fn group_by(mut self, column: &str) -> Self {
22 self.group_by.push(column.to_string());
23 self
24 }
25
26 pub fn having_eq<T: Into<Value>>(mut self, column: &str, value: T) -> Self {
28 self.having_conditions.push(WhereCondition {
29 column: column.to_string(),
30 operator: QueryOperator::Equal,
31 value: Some(value.into()),
32 values: Vec::new(),
33 });
34 self
35 }
36
37 pub fn having<T: Into<Value>>(mut self, column: &str, operator: QueryOperator, value: T) -> Self {
39 self.having_conditions.push(WhereCondition {
40 column: column.to_string(),
41 operator,
42 value: Some(value.into()),
43 values: Vec::new(),
44 });
45 self
46 }
47
48 pub fn having_raw(mut self, raw_condition: &str) -> Self {
50 self.having_conditions.push(WhereCondition {
51 column: "".to_string(), operator: QueryOperator::Raw,
53 value: Some(Value::String(raw_condition.to_string())),
54 values: Vec::new(),
55 });
56 self
57 }
58}