diff --git a/crates/libs/lib-core/src/model/base.rs b/crates/libs/lib-core/src/model/base.rs index 14c3fa9..72f175c 100644 --- a/crates/libs/lib-core/src/model/base.rs +++ b/crates/libs/lib-core/src/model/base.rs @@ -30,6 +30,9 @@ pub enum TimestampIden { pub trait DbBmc { const TABLE: &'static str; + /// Specifies that the table for this Bmc has timestamps (cid, ctime, mid, mtime) columns. + /// This will allow the code to update those as needed. + const TIMESTAMPED: bool; fn table_ref() -> TableRef { TableRef::Table(SIden(Self::TABLE).into_iden()) @@ -74,7 +77,9 @@ where // -- Extract fields (name / sea-query value expression) let mut fields = data.not_none_fields(); - add_timestamps_for_create(&mut fields, ctx.user_id()); + if MC::TIMESTAMPED { + add_timestamps_for_create(&mut fields, ctx.user_id()); + } let (columns, sea_values) = fields.for_sea_insert(); // -- Build query @@ -172,7 +177,9 @@ where let db = mm.db(); let mut fields = data.not_none_fields(); - add_timestamps_for_update(&mut fields, ctx.user_id()); + if MC::TIMESTAMPED { + add_timestamps_for_update(&mut fields, ctx.user_id()); + } let fields = fields.for_sea_update(); // -- Build query diff --git a/crates/libs/lib-core/src/model/project.rs b/crates/libs/lib-core/src/model/project.rs index bf1c315..f027828 100644 --- a/crates/libs/lib-core/src/model/project.rs +++ b/crates/libs/lib-core/src/model/project.rs @@ -75,6 +75,7 @@ pub struct ProjectBmc; impl DbBmc for ProjectBmc { const TABLE: &'static str = "project"; + const TIMESTAMPED: bool = true; } impl ProjectBmc { diff --git a/crates/libs/lib-core/src/model/task.rs b/crates/libs/lib-core/src/model/task.rs index 5f57162..d1da4ea 100644 --- a/crates/libs/lib-core/src/model/task.rs +++ b/crates/libs/lib-core/src/model/task.rs @@ -66,6 +66,7 @@ pub struct TaskBmc; impl DbBmc for TaskBmc { const TABLE: &'static str = "task"; + const TIMESTAMPED: bool = true; } impl TaskBmc { diff --git a/crates/libs/lib-core/src/model/user.rs b/crates/libs/lib-core/src/model/user.rs index 1242edd..4086d94 100644 --- a/crates/libs/lib-core/src/model/user.rs +++ b/crates/libs/lib-core/src/model/user.rs @@ -72,6 +72,7 @@ pub struct UserBmc; impl DbBmc for UserBmc { const TABLE: &'static str = "user"; + const TIMESTAMPED: bool = true; } impl UserBmc { @@ -126,7 +127,9 @@ impl UserBmc { // -- Prep the data let mut fields = Fields::new(vec![Field::new(UserIden::Pwd, pwd.into())]); - add_timestamps_for_update(&mut fields, ctx.user_id()); + if Self::TIMESTAMPED { + add_timestamps_for_update(&mut fields, ctx.user_id()); + } // -- Build query let fields = fields.for_sea_update();