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
129
130
131
132
133
134
135
136
137
138
139
/// This modules contains types and traits for an Entity, ActiveMode, Model, PrimaryKey, ForeignKey and Relations.
///
/// // An Entity
/// A unit struct implements [EntityTrait](crate::EntityTrait) representing a table in the database.
///
/// This trait contains the properties of an entity including
///
/// - The Table Name which is implemented by [EntityName](crate::EntityName)
/// - The Column which is implemented by [ColumnTrait](crate::ColumnTrait)
/// - A Relation which is implemented by [RelationTrait](crate::RelationTrait)
/// - The Primary Key which is implemented by [PrimaryKeyTrait](crate::PrimaryKeyTrait)
/// and [PrimaryKeyToColumn](crate::PrimaryKeyToColumn)
///
/// This trait also provides an API for CRUD actions
///
/// #### Example for creating an Entity, Model and ActiveModel
/// ```
/// #[cfg(feature = "macros")]
/// # use sea_orm::entity::prelude::*;
/// use sea_orm::ActiveModelBehavior;
/// use sea_orm::ColumnDef;
/// use sea_orm::ColumnTrait;
/// use sea_orm::ColumnType;
/// use sea_orm::EntityName;
/// use sea_orm::PrimaryKeyTrait;
/// use sea_orm::RelationDef;
/// use sea_orm::RelationTrait;
///
/// // Use [DeriveEntity] to derive the EntityTrait automatically
/// #[derive(Copy, Clone, Default, Debug, DeriveEntity)]
/// pub struct Entity;
///
/// /// The [EntityName] describes the name of a table
/// impl EntityName for Entity {
/// fn table_name(&self) -> &'static str {
/// "filling"
/// }
/// }
///
/// // Create a Model for the Entity through [DeriveModel].
/// // The `Model` handles `READ` operations on a table in a database.
/// // The [DeriveActiveModel] creates a way to perform `CREATE` , `READ` and `UPDATE` operations
/// // in a database
/// #[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)]
/// pub struct Model {
/// pub id: i32,
/// pub name: String,
/// }
///
/// // Use the [DeriveColumn] to create a Column for an the table called Entity
/// // The [EnumIter] which creates a new type that iterates of the variants of a Column.
/// #[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
/// pub enum Column {
/// Id,
/// Name,
/// }
///
/// // Create a PrimaryKey for the Entity using the [PrimaryKeyTrait]
/// // The [EnumIter] which creates a new type that iterates of the variants of a PrimaryKey.
/// #[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)]
/// pub enum PrimaryKey {
/// Id,
/// }
///
/// // Or implement the [PrimaryKeyTrait] manually instead of using the macro [DerivePrimaryKey]
/// impl PrimaryKeyTrait for PrimaryKey {
/// type ValueType = i32;
///
/// fn auto_increment() -> bool {
/// true
/// }
/// }
///
/// #[derive(Copy, Clone, Debug, EnumIter)]
/// pub enum Relation {}
///
/// impl ColumnTrait for Column {
/// type EntityName = Entity;
///
/// fn def(&self) -> ColumnDef {
/// match self {
/// Self::Id => ColumnType::Integer.def(),
/// Self::Name => ColumnType::String(StringLen::None).def(),
/// }
/// }
/// }
///
/// // Create a Relation for the Entity
/// impl RelationTrait for Relation {
/// fn def(&self) -> RelationDef {
/// unimplemented!()
/// }
/// }
///
/// // Implement user defined operations for CREATE, UPDATE and DELETE operations
/// // to create an ActiveModel using the [ActiveModelBehavior]
/// impl ActiveModelBehavior for ActiveModel {}
/// ```
pub
/// Re-export common types from the entity
pub
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use EntityLoaderTrait;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;