extern crate postgres; extern crate r2d2; extern crate r2d2_postgres; extern crate rustc_serialize; #[macro_use] extern crate lazy_static; #[macro_use] extern crate log; #[macro_use] extern crate repos; use repos::*; reposable! {struct Account(account){ name: Option, email: Option, url: Option, password: Option, role: Option, article_count: i32, published_article_count: i32, avatar: Option, }} fn main() { init(&PostgresConfig { host: "127.0.0.1".into(), port: "5432".into(), user_name: "brog".into(), password: "123456".into(), db_name: "brog".into(), }); let vec = find_list::("select * from account", &[]); println!("vec.len:{}", vec.len()); let vec = Account::list(); println!("vec.len:{}", vec.len()); let count=Account::count(); println!("count:{}", count); let count=Account::count2("id>$1 and id <$2",&[&2,&10]); println!("count2:{}", count); let mut account = Account::get(2).unwrap(); account.email = Some("hike@msn.cn".into()); println!("account:{:?}", account); println!("field_value:{:?}",account.get_value("email")); account.update(); account.name=Some("Leo Li".to_string()); account.partial_update(vec!["name"]); account.exclude_update(vec!["name","email","url","password"]); account.new(); }