pg-helper 0.2.3

postgres database helper
Documentation
use crate::PgType;
use std::collections::BTreeMap;

#[derive(Debug, Default, Clone)]
pub struct PgTableDesc {
    pub data: BTreeMap<String, Vec<PgTableItem>>,
}

impl PgTableDesc {
    pub fn get_data(&self, key: String, case_sensitive: bool) -> Option<&Vec<PgTableItem>> {
        let key = if case_sensitive {
            key
        } else {
            key.to_uppercase()
        };
        self.data.get(&key)
    }
}

#[derive(Debug, Clone)]
pub struct PgTableItem {
    // column name
    pub name: String,
    // pg table id
    pub table_id: usize,
    // column index
    pub col_index: usize,
    // pg data type
    pub r#type: PgType,
    // column date type length
    pub length: usize,
    // column date type scale
    pub scale: usize,
    pub nullable: bool,
    pub default_val: Option<String>,
    pub table_name: String,
    pub create_time: String,
}