sea_query/query/
mod.rs

1//! Query statements (select, insert, update & delete).
2//!
3//! # Usage
4//!
5//! - Query Select, see [`SelectStatement`]
6//! - Query Insert, see [`InsertStatement`]
7//! - Query Update, see [`UpdateStatement`]
8//! - Query Delete, see [`DeleteStatement`]
9
10mod case;
11mod condition;
12mod delete;
13mod insert;
14mod on_conflict;
15mod ordered;
16mod returning;
17mod select;
18mod traits;
19mod update;
20mod window;
21mod with;
22
23pub use case::*;
24pub use condition::*;
25pub use delete::*;
26pub use insert::*;
27pub use on_conflict::*;
28pub use ordered::*;
29pub use returning::*;
30pub use select::*;
31pub use traits::*;
32pub use update::*;
33pub use window::*;
34pub use with::*;
35
36/// Shorthand for constructing any table query
37#[derive(Debug, Clone)]
38pub struct Query;
39
40/// All available types of table query
41#[derive(Debug, Clone)]
42pub enum QueryStatement {
43    Select(SelectStatement),
44    Insert(InsertStatement),
45    Update(UpdateStatement),
46    Delete(DeleteStatement),
47}
48
49#[derive(Debug, Clone, PartialEq)]
50pub enum SubQueryStatement {
51    SelectStatement(SelectStatement),
52    InsertStatement(InsertStatement),
53    UpdateStatement(UpdateStatement),
54    DeleteStatement(DeleteStatement),
55    WithStatement(WithQuery),
56}
57
58impl Query {
59    /// Construct table [`SelectStatement`]
60    pub fn select() -> SelectStatement {
61        SelectStatement::new()
62    }
63
64    /// Construct table [`InsertStatement`]
65    pub fn insert() -> InsertStatement {
66        InsertStatement::new()
67    }
68
69    /// Construct table [`UpdateStatement`]
70    pub fn update() -> UpdateStatement {
71        UpdateStatement::new()
72    }
73
74    /// Construct table [`DeleteStatement`]
75    pub fn delete() -> DeleteStatement {
76        DeleteStatement::new()
77    }
78
79    /// Construct [`WithClause`]
80    pub fn with() -> WithClause {
81        WithClause::new()
82    }
83
84    /// Construct [`Returning`]
85    pub fn returning() -> Returning {
86        Returning::new()
87    }
88}