2020-05-20 17:05:59 +00:00
|
|
|
use comunic_server::data::config::{conf, Config};
|
2020-05-21 07:21:58 +00:00
|
|
|
use comunic_server::helpers::database;
|
2020-05-21 13:28:07 +00:00
|
|
|
use comunic_server::controllers::server;
|
2020-05-22 06:51:15 +00:00
|
|
|
use comunic_server::helpers::database::QueryInfo;
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
struct User {
|
|
|
|
id : i64,
|
|
|
|
name: String,
|
|
|
|
}
|
2020-05-21 07:38:41 +00:00
|
|
|
|
2020-05-21 13:28:07 +00:00
|
|
|
#[actix_rt::main]
|
|
|
|
async fn main() -> std::io::Result<()> {
|
2020-05-20 17:05:59 +00:00
|
|
|
|
|
|
|
// Load configuration
|
|
|
|
Config::load("config.yaml").expect("Could not load configuration!");
|
|
|
|
|
2020-05-21 07:21:58 +00:00
|
|
|
// Connect to the database
|
|
|
|
database::connect(&conf().database).expect("Could not connect to database!");
|
2020-05-20 17:05:59 +00:00
|
|
|
|
2020-05-22 06:51:15 +00:00
|
|
|
let mut query = QueryInfo::new("user");
|
|
|
|
query.cond("age", "190");
|
|
|
|
//query.cond("id", "1");
|
|
|
|
let res = database::query_row(query, |res| Ok(User {
|
|
|
|
id: res.get_int64("id")?,
|
|
|
|
name: res.get_str("name")?,
|
|
|
|
})).unwrap();
|
|
|
|
|
|
|
|
println!("{:#?}", res);
|
|
|
|
|
2020-05-21 13:28:07 +00:00
|
|
|
// Start the server
|
|
|
|
server::start_server(conf()).await
|
2020-05-20 15:46:05 +00:00
|
|
|
}
|