pub trait Model {
fn table(&mut self) -> String;
fn title(&mut self) -> String;
fn fields(&mut self) -> JsonValue;
fn action(&mut self, name: &str) -> Box<dyn Action>;
fn version(&mut self) -> String { ... }
fn unique(&mut self) -> Vec<String> ⓘ { ... }
fn index(&mut self) -> Vec<Vec<String>> ⓘ { ... }
fn primary_key(&mut self) -> String { ... }
fn auto(&mut self) -> bool { ... }
fn json(&mut self) -> ModelTable { ... }
fn create_json_file(&mut self, path: &str) -> bool { ... }
}
Expand description
模型
Required Methods§
Provided Methods§
sourcefn primary_key(&mut self) -> String
fn primary_key(&mut self) -> String
主键
sourcefn json(&mut self) -> ModelTable
fn json(&mut self) -> ModelTable
创建安装json
sourcefn create_json_file(&mut self, path: &str) -> bool
fn create_json_file(&mut self, path: &str) -> bool
创建安装文件
Examples found in repository?
examples/db.rs (line 11)
5 6 7 8 9 10 11 12 13 14 15 16
fn main() {
let root_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
// 生成数据库文件
let sql_path = root_path.join("model");
let sql_path = sql_path.to_str().unwrap();
let test = plugins("test").model("testmodel").create_json_file(sql_path);
println!("{}", test);
//
// let (code, data, msg) = plugins("test").model("testmodel").action("testaction").run(object! {});
// println!("{} {} {}", code, data, msg);
}