rustorm 0.0.5

A simple ORM and code generator for rust
extern crate rustorm;
extern crate uuid;
extern crate chrono;
extern crate rustc_serialize;



use rustorm::db::postgres::Postgres;
use rustorm::codegen;
use uuid::Uuid;
use chrono::datetime::DateTime;
use chrono::offset::utc::UTC;
use rustc_serialize::json;

use gen::bazaar::Product; //check folder `./examples/gen/bazaar/product.rs`

// this is the generated module, generated by generate_model_code example
mod gen;


fn main(){
    let pg = Postgres::with_connection("postgres://postgres:p0stgr3s@localhost/bazaar_v6");
    let sql = "select * from bazaar.product".to_string();
    let stmt = pg.conn.prepare(&sql).unwrap();
    for row in stmt.query(&[]).unwrap() {
        let product = Product{
            product_id: row.get("product_id"),
            barcode: row.get_opt("barcode").ok(),
            currency_id: row.get_opt("currency_id").ok(),
            info: row.get_opt("info").ok(),
            is_service: row.get_opt("is_service").ok(),
            owner_id: row.get_opt("owner_id").ok(),
            parent_product_id: row.get_opt("parent_product_id").ok(),
            price: row.get_opt("price").ok(),
            seq_no: row.get_opt("seq_no").ok(),
            tags: row.get_opt("tags").ok(),
            unit: row.get_opt("unit").ok(),
            upfront_fee: row.get_opt("upfront_fee").ok(),
            use_parent_price: row.get_opt("use_parent_price").ok(),
            active: row.get("active"),
            client_id: row.get_opt("client_id").ok(),
            created: row.get("created"),
            created_by: row.get_opt("created_by").ok(),
            description: row.get_opt("description").ok(),
            help: row.get_opt("help").ok(),
            name: row.get_opt("name").ok(),
            organization_id: row.get_opt("organization_id").ok(),
            priority:row.get_opt("priority").ok(),
            updated:row.get("updated"),
            updated_by: row.get_opt("updated_by").ok(),
            owner:None,
            currency:None,
            availability:None,
            category:vec![],
            photo:vec![],
            review:vec![]
        };
        println!("product:{}({})", product.name.as_ref().unwrap(), product.product_id);
        println!("{},", json::as_pretty_json(&product));
    }
}