1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//! An orm that is simple to use and prevents runtime errors by using rust's
//! rich type system to enforce sql logic at compile time.
//!
//! # Usage
//!
//! The core of this crate is the [`Table`] derive macro, which you can derive
//! on your rust structs to tell the orm that they represent tables in your
//! database.
//!
//! # Example
//! ```rust
//! #[derive(Debug, Table)]
//! pub struct Person {
//! id: i32,
//! name: String,
//! age: i32,
//!
//! #[table(foreign_key(School))]
//! school_id: i32,
//! }
//!
//! #[derive(Debug, Table)]
//! pub struct School {
//! id: i32,
//! name: String,
//! }
//!
//! struct MyMigration;
//! migration! { MyMigration => school, person }
//!
//! let pool =
//! DatabaseConnectionPool::connect("postgres://postgres:postgres@localhost/some_database")
//! .await?;
//!
//! MyMigration::down(&pool).await?;
//! MyMigration::up(&pool).await?;
//!
//! let school_id = school::new { name: "Stanford" }
//! .insert_returning_value(returning!(school::id), &pool)
//! .await?;
//!
//! person::new {
//! name: "James",
//! age: &35,
//! school_id,
//! }
//! .insert(&pool)
//! .await?;
//!
//! #[derive(FromQueryResult)]
//! struct PersonNameAndSchoolName {
//! person_name: String,
//! school_name: String,
//! }
//! let person_and_school_names = person::table
//! .inner_join(school::table)
//! .find()
//! .select(select_values!(
//! person::name as person_name,
//! school::name as school_name
//! ))
//! .load_all::<PersonNameAndSchoolName>(&pool)
//! .await?;
//!
//! struct AgeSumOfSchool {
//! school_name: String,
//! age_sum: i64,
//! }
//! let age_sum_of_each_school_from_highest_to_lowest = person::table
//! .inner_join(school::table)
//! .find()
//! .select(select_values!(
//! school::name as school_name,
//! person::age.sum() as age_sum
//! ))
//! .group_by(school::id)
//! .order_by_selected_value_descending(selected_value_to_order_by!(age_sum))
//! .load_all::<AgeSumOfSchool>(&pool)
//! .await?;
//!
//! let old_enough_people_ids = person::table
//! .find()
//! .filter(person::age.greater_equals(20))
//! .select(select_values!(person::id))
//! .load_all_values(&pool)
//! .await?;
//! ```
//!
//! For more examples, check out the examples directory.
//!
//! [`Table`]: gorm_macros::Table
//!
//! # Migration Cli
//!
//! If you want to create a cli to manage your migration, you can use the
//! `migration_cli` feature flag. This feature flag will provide you the
//! `migration_cli_main` function which you can call in your main function and
//! it will take care of the rest.
//!
//! For an example of this, check out the `migration_cli` example in the
//! examples directory.
pub use async_trait;
pub use bytes;
pub use tokio_postgres;
pub use *;
pub use futures;
pub use ;
pub use Decimal;
pub use ;
pub use migration_cli_main;