add table macro
extern crate lazy_static;
extern crate once_cell;
#[macro_use]
-extern crate serde_json;
-#[macro_use]
extern crate rbatis_macro_driver;
+#[macro_use]
+extern crate serde_json;
-pub use crate::core::{convert::StmtConvert, db::DriverType, error::Error, error::Result};
pub use rbatis_core as core;
-pub use rbatis_macro_driver::{crud_enable, py_sql, sql, CRUDTable};
+
+pub use rbatis_macro_driver::{crud_enable, CRUDTable, py_sql, sql};
+
+pub use crate::core::{convert::StmtConvert, db::DriverType, error::Error, error::Result};
pub mod crud;
pub mod plugin;
@@ -25,3 +27,32 @@ pub mod tx;
#[macro_use]
pub mod utils;
pub mod wrapper;
+
+
+/// Simplifies table construction by relying on the Default interface
+///
+/// step1: impl Default
+/// impl Default for BizActivity{
+/// fn default() -> Self {
+/// Self{
+/// id:None,
+/// name:None,
+/// delete_flag:None,
+/// }
+/// }
+/// }
+///
+/// let activity = rbatis::table!(BizActivity{
+/// id : Some("12312".to_string()),
+/// delete_flag : Some(1),
+/// });
+#[macro_export]
+macro_rules! table {
+ ($t:ty{ $($key:ident:$value:expr,)+ }) => {
+ {
+ let mut temp_table_data = <$t>::default();
+ $(temp_table_data.$key=$value;)+
+ temp_table_data
+ }
+ }
+}
\ No newline at end of file
