Struct cuppa::database::DataBase[][src]

pub struct DataBase {
    pub host: &'static str,
    pub port: u16,
    pub db: &'static str,
    pub user: &'static str,
    pub pass: &'static str,
    pub pool: Pool,
}

Fields

host: &'static strport: u16db: &'static struser: &'static strpass: &'static strpool: Pool

Implementations

EXAMPLE
let db = DataBase::new("localhost", 3306, "rust", "root", "");

Mix of Insert / Update: The method checks if a row already exists and update it; otherwise, insert a new record. Both cases return the affected row.

EXAMPLE
let mut data = Map::new();
    data.insert("name".to_string(), json!("Zulay"));
 
let row = db.add("users".to_string(), data, "id = 333".to_string(), "".to_string());
println!("{:?}", row);
Example
let mut data = Map::new();
    data.insert("name".to_string(), json!("Francisco"));
 
let row = db.insert("users".to_string(), data, "".to_string());
println!("{:?}", row);
Example
let mut data = Map::new();
    data.insert("name".to_string(), json!("Francisco"));

let row = db.update("users".to_string(), data, "id = 1".to_string(), "".to_string());
println!("{:?}", row);
Example
let rows = db.get_list("users".to_string(), "".to_string(), "10".to_string(), "id ASC".to_string(), "id, name".to_string());
println!("{:?}", rows);
Example
let total_rows = db.get_total_rows("users".to_string(), "".to_string());
println!("{:?}", total_rows);
Example
let row = db.get_row("users".to_string(), "id = 1".to_string(), "".to_string(), "".to_string());
println!("{:?}", row);
Example
let rows = db.sql("SELECT * from users".to_string()).unwrap();
println!("{:?}", rows);

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.