//! WARNING: This file is generated, derived from table system.record, DO NOT EDIT
use chrono::datetime::DateTime;
use chrono::offset::utc::UTC;
use gen::column;
use gen::schema;
use gen::table;
use rustc_serialize::json::Json;
use rustc_serialize::json::ToJson;
use rustorm::dao::Dao;
use rustorm::dao::IsDao;
use rustorm::dao::Type;
use rustorm::dao::Value;
use rustorm::query::Operand;
use rustorm::table::Column;
use rustorm::table::IsTable;
use rustorm::table::Table;
use uuid::Uuid;
///
/// All User table should inherit from this one
///
#[derive(RustcEncodable)]
#[derive(Debug, Clone)]
pub struct Record {
/// @Active
/// default: 'true'
/// not nullable
/// db data type: boolean
pub active: bool,
/// db data type: character varying
pub description: Option<String>,
/// db data type: text
pub help: Option<String>,
/// db data type: character varying
pub name: Option<String>,
/// --inherited--
/// db data type: uuid
pub client_id: Option<Uuid>,
/// default: 'now()'
/// not nullable
/// --inherited--
/// db data type: timestamp with time zone
pub created: DateTime<UTC>,
/// --inherited--
/// db data type: uuid
pub created_by: Option<Uuid>,
/// --inherited--
/// db data type: uuid
pub organization_id: Option<Uuid>,
/// --inherited--
/// db data type: double precision
pub priority: Option<f64>,
/// default: 'now()'
/// not nullable
/// --inherited--
/// db data type: timestamp with time zone
pub updated: DateTime<UTC>,
/// --inherited--
/// db data type: uuid
pub updated_by: Option<Uuid>,
}
impl IsDao for Record {
fn from_dao(dao: &Dao) -> Self {
Record {
organization_id: dao.get_opt(column::organization_id),
client_id: dao.get_opt(column::client_id),
created: dao.get(column::created),
created_by: dao.get_opt(column::created_by),
updated: dao.get(column::updated),
updated_by: dao.get_opt(column::updated_by),
priority: dao.get_opt(column::priority),
name: dao.get_opt(column::name),
description: dao.get_opt(column::description),
help: dao.get_opt(column::help),
active: dao.get(column::active),
}
}
fn to_dao(&self) -> Dao {
let mut dao = Dao::new();
match self.organization_id {
Some(ref _value) => dao.set(column::organization_id, _value),
None => dao.set_null(column::organization_id)
}
match self.client_id {
Some(ref _value) => dao.set(column::client_id, _value),
None => dao.set_null(column::client_id)
}
dao.set(column::created, &self.created);
match self.created_by {
Some(ref _value) => dao.set(column::created_by, _value),
None => dao.set_null(column::created_by)
}
dao.set(column::updated, &self.updated);
match self.updated_by {
Some(ref _value) => dao.set(column::updated_by, _value),
None => dao.set_null(column::updated_by)
}
match self.priority {
Some(ref _value) => dao.set(column::priority, _value),
None => dao.set_null(column::priority)
}
match self.name {
Some(ref _value) => dao.set(column::name, _value),
None => dao.set_null(column::name)
}
match self.description {
Some(ref _value) => dao.set(column::description, _value),
None => dao.set_null(column::description)
}
match self.help {
Some(ref _value) => dao.set(column::help, _value),
None => dao.set_null(column::help)
}
dao.set(column::active, &self.active);
dao
}
}
impl ToJson for Record {
fn to_json(&self) -> Json {
self.to_dao().to_json()
}
}
impl Default for Record {
fn default() -> Self {
Record{
organization_id: Default::default(),
client_id: Default::default(),
created: UTC::now(),
created_by: Default::default(),
updated: UTC::now(),
updated_by: Default::default(),
priority: Default::default(),
name: Default::default(),
description: Default::default(),
help: Default::default(),
active: Default::default(),
}
}
}
impl IsTable for Record {
fn table() -> Table {
Table {
schema: Some(schema::system.to_owned()),
name: table::record.to_owned(),
parent_table: Some(table::base.to_owned()),
sub_table: vec![table::address.to_owned(),table::api_key.to_owned(),table::cart.to_owned(),table::cart_line.to_owned(),table::category.to_owned(),table::client.to_owned(),table::invoice.to_owned(),table::order_line.to_owned(),table::orders.to_owned(),table::organization.to_owned(),table::photo.to_owned(),table::photo_sizes.to_owned(),table::product.to_owned(),table::review.to_owned(),table::settings.to_owned(),table::user_info.to_owned(),table::user_location.to_owned(),table::user_review.to_owned(),table::users.to_owned(),table::wishlist.to_owned(),table::wishlist_line.to_owned(),table::country.to_owned(),table::currency.to_owned(),table::exchange_rate.to_owned(),],
comment: Some("All User table should inherit from this one".to_owned()),
columns: vec![
Column {
name: column::organization_id.to_owned(),
data_type: Type::Uuid,
db_data_type: "uuid".to_owned(),
is_primary: false, is_unique: false, not_null: false, is_inherited: true,
default: None,
comment: None,
foreign: None,
},
Column {
name: column::client_id.to_owned(),
data_type: Type::Uuid,
db_data_type: "uuid".to_owned(),
is_primary: false, is_unique: false, not_null: false, is_inherited: true,
default: None,
comment: None,
foreign: None,
},
Column {
name: column::created.to_owned(),
data_type: Type::DateTime,
db_data_type: "timestamp with time zone".to_owned(),
is_primary: false, is_unique: false, not_null: true, is_inherited: true,
default: Some(Operand::Value(Value::String("'now()'".to_owned()))),
comment: None,
foreign: None,
},
Column {
name: column::created_by.to_owned(),
data_type: Type::Uuid,
db_data_type: "uuid".to_owned(),
is_primary: false, is_unique: false, not_null: false, is_inherited: true,
default: None,
comment: None,
foreign: None,
},
Column {
name: column::updated.to_owned(),
data_type: Type::DateTime,
db_data_type: "timestamp with time zone".to_owned(),
is_primary: false, is_unique: false, not_null: true, is_inherited: true,
default: Some(Operand::Value(Value::String("'now()'".to_owned()))),
comment: None,
foreign: None,
},
Column {
name: column::updated_by.to_owned(),
data_type: Type::Uuid,
db_data_type: "uuid".to_owned(),
is_primary: false, is_unique: false, not_null: false, is_inherited: true,
default: None,
comment: None,
foreign: None,
},
Column {
name: column::priority.to_owned(),
data_type: Type::F64,
db_data_type: "double precision".to_owned(),
is_primary: false, is_unique: false, not_null: false, is_inherited: true,
default: None,
comment: None,
foreign: None,
},
Column {
name: column::name.to_owned(),
data_type: Type::String,
db_data_type: "character varying".to_owned(),
is_primary: false, is_unique: false, not_null: false, is_inherited: false,
default: None,
comment: None,
foreign: None,
},
Column {
name: column::description.to_owned(),
data_type: Type::String,
db_data_type: "character varying".to_owned(),
is_primary: false, is_unique: false, not_null: false, is_inherited: false,
default: None,
comment: None,
foreign: None,
},
Column {
name: column::help.to_owned(),
data_type: Type::String,
db_data_type: "text".to_owned(),
is_primary: false, is_unique: false, not_null: false, is_inherited: false,
default: None,
comment: None,
foreign: None,
},
Column {
name: column::active.to_owned(),
data_type: Type::Bool,
db_data_type: "boolean".to_owned(),
is_primary: false, is_unique: false, not_null: true, is_inherited: false,
default: Some(Operand::Value(Value::String("'true'".to_owned()))),
comment: Some("@Active".to_owned()),
foreign: None,
},
],
is_view: false,
}
}
}
// Generated columns for easier development of dynamic queries without sacrificing wrong spelling of column names
#[allow(non_upper_case_globals)]
#[allow(dead_code)]
pub static organization_id: &'static str = "record.organization_id";
#[allow(non_upper_case_globals)]
#[allow(dead_code)]
pub static client_id: &'static str = "record.client_id";
#[allow(non_upper_case_globals)]
#[allow(dead_code)]
pub static created: &'static str = "record.created";
#[allow(non_upper_case_globals)]
#[allow(dead_code)]
pub static created_by: &'static str = "record.created_by";
#[allow(non_upper_case_globals)]
#[allow(dead_code)]
pub static updated: &'static str = "record.updated";
#[allow(non_upper_case_globals)]
#[allow(dead_code)]
pub static updated_by: &'static str = "record.updated_by";
#[allow(non_upper_case_globals)]
#[allow(dead_code)]
pub static priority: &'static str = "record.priority";
#[allow(non_upper_case_globals)]
#[allow(dead_code)]
pub static name: &'static str = "record.name";
#[allow(non_upper_case_globals)]
#[allow(dead_code)]
pub static description: &'static str = "record.description";
#[allow(non_upper_case_globals)]
#[allow(dead_code)]
pub static help: &'static str = "record.help";
#[allow(non_upper_case_globals)]
#[allow(dead_code)]
pub static active: &'static str = "record.active";