mysql_connector/model/
mod.rs1mod active_model;
2mod from_query_result;
3mod into_query;
4mod plain;
5
6#[cfg(test)]
7mod test;
8
9use crate::types::Value;
10
11pub use {
12 active_model::{
13 ActiveModel, ActiveReference, ActiveValue, HasActiveModel, NamedValue, UpdateModel,
14 },
15 from_query_result::{FromQueryResult, FromQueryResultMapping},
16 into_query::{IntoQuery, QueryColumn, QueryColumnReference},
17};
18
19pub trait ModelData: std::fmt::Debug + Sized {
20 const TABLE: &'static str;
21 const TABLE_WITH_POINT: &'static str;
22}
23
24pub trait Model: ModelData + HasActiveModel {
25 const PRIMARY: &'static str;
26 const AUTO_INCREMENT: bool;
27
28 type Primary: Into<Value>;
29
30 fn primary(&self) -> Self::Primary;
31
32 fn active_model() -> <Self as HasActiveModel>::ActiveModel {
33 <Self as HasActiveModel>::ActiveModel::default()
34 }
35
36 fn update_model(&self) -> UpdateModel<Self> {
37 UpdateModel::new(self.primary())
38 }
39}