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
use Database;
/// Trait that can be implemented on a `struct` to associate a basic SQL schema
/// with it.
///
/// # Example
///
/// ```
/// use miniorm::prelude::*;
/// use sqlx::Postgres;
///
/// struct Todo {
/// description: String,
/// done: bool,
/// }
///
/// impl Schema<Postgres> for Todo {
/// const MINIORM_CREATE_TABLE: &'static str = r#"
/// CREATE TABLE IF NOT EXISTS todo (
/// id BIGSERIAL PRIMARY KEY,
/// description TEXT NOT NULL,
/// done BOOLEAN NOT NULL
/// )"#;
/// const MINIORM_DROP_TABLE: &'static str = r#"
/// DROP TABLE IF EXISTS todo"#;
/// const MINIORM_CREATE: &'static str = r#"
/// INSERT INTO todo (description, done) VALUES ($1,$2) RETURNING id"#;
/// const MINIORM_READ: &'static str = r#"
/// SELECT selection, done FROM todo WHERE id=$1"#;
/// const MINIORM_LIST: &'static str = r#"
/// SELECT selection, done FROM todo ORDER BY id"#;
/// const MINIORM_COUNT: &'static str = r#"
/// SELECT COUNT(id) AS count FROM todo"#;
/// const MINIORM_UPDATE: &'static str = r#"
/// UPDATE todo SET selection=$1, done=$2 WHERE id=$2"#;
/// const MINIORM_DELETE: &'static str = r#"
/// DELETE FROM todo WHERE id=$1"#;
/// const MINIORM_DELETE_ALL: &'static str = r#"
/// DELETE FROM todo"#;
/// const MINIORM_TABLE_NAME: &'static str = "todo";
/// const MINIORM_COLUMNS: &'static [&'static str] = &[
/// "description",
/// "done",
/// ];
/// }
/// ```
///
/// # Note
///
/// This trait can be derived automatically using the [Entity](miniorm_macros::Entity)
/// derive macro.
///