ruwebframe 0.1.0

A brief description of your crate.
Documentation
use crate::rubase::{rudto, ruentity};
use crate::rucfg ;
use postgres::Client;
use tokio_postgres::NoTls;

pub struct Database {
    gorm: rudto::Gorm,
    datasource: rudto::DataSource,
}

impl ruentity::BaseEntitySingle for Database {}
impl Database {
    pub fn new() -> Self {
        let config = rucfg::find_bean_ru_config().unwrap().read();
        Database {
            gorm: config.gorm,
            datasource: config.datasource,
        }
    }
    pub fn conn() -> Result<Client, postgres::Error> {
        let mut client = Client::connect(
            rudto::DataSource::new().buildUrl().to_string().as_str(),
            NoTls, // 如果需要 TLS 可换成 openssl 等
        )?;
        Ok(client)
    }
}