aboutsummaryrefslogtreecommitdiffstats
path: root/rust/src
diff options
context:
space:
mode:
Diffstat (limited to 'rust/src')
-rw-r--r--rust/src/api_server.rs24
-rw-r--r--rust/src/database_models.rs5
-rw-r--r--rust/src/lib.rs1
3 files changed, 23 insertions, 7 deletions
diff --git a/rust/src/api_server.rs b/rust/src/api_server.rs
index 9fbcbc57..b8ec3abd 100644
--- a/rust/src/api_server.rs
+++ b/rust/src/api_server.rs
@@ -35,26 +35,40 @@ impl Api for Server {
) -> Box<Future<Item = ContainerIdGetResponse, Error = ApiError> + Send> {
let conn = self.db_pool.get().expect("db_pool error");
let id = uuid::Uuid::parse_str(&id).unwrap();
+ let (ident, rev): (ContainerIdentRow, Option<ContainerRevRow>) = container_ident::table
+ .find(id)
+ .left_outer_join(container_rev::table)
+ .first(&conn)
+ .expect("error loading container");
+/*
+ let (ident, rev): (ContainerIdentRow, Option<ContainerRevRow>) = container_ident::table
+ .left_join(container_rev::table)
+ .filter(container_ident::id.equals(id))
+ .first(&conn)
+ .expect("error loading container");
+*/
+/*
let c: ContainerIdentRow = container_ident::table
.find(id)
.first(&conn)
.expect("error loading container");
//let c: i64 = container_rev::table.count().first(&conn).expect("DB Error");
println!("container count: {:?}", c);
+*/
- let ce = ContainerEntity {
+ let entity = ContainerEntity {
issn: None,
publisher: Some("Hello!".into()),
parent: None,
name: None,
state: None,
- ident: Some(c.id.to_string()),
- revision: c.rev_id.map(|v| v as isize),
- redirect: None,
+ ident: Some(ident.id.to_string()),
+ revision: ident.rev_id.map(|v| v as isize),
+ redirect: ident.redirect_id.map(|u| u.to_string()),
editgroup: None,
};
Box::new(futures::done(Ok(
- ContainerIdGetResponse::FetchASingleContainerById(ce),
+ ContainerIdGetResponse::FetchASingleContainerById(entity),
)))
}
diff --git a/rust/src/database_models.rs b/rust/src/database_models.rs
index 7153d18f..6c899ccf 100644
--- a/rust/src/database_models.rs
+++ b/rust/src/database_models.rs
@@ -1,5 +1,6 @@
use chrono;
+use serde_json;
use uuid::Uuid;
//use diesel::prelude::*;
@@ -20,7 +21,7 @@ macro_rules! entity_structs {
pub rev_id: Option<i64>,
pub redirect_id: Option<Uuid>,
pub editgroup_id: i64,
- //pub extra_json: Option<Json>,
+ //pub extra_json: Option<String>,
}
#[derive(Debug, Queryable, Identifiable, Associations, AsChangeset)]
@@ -38,7 +39,7 @@ macro_rules! entity_structs {
#[table_name = "container_rev"]
pub struct ContainerRevRow {
pub id: i64,
- //extra_json: Option<Json>,
+ //pub extra_json: Option<serde_json::Value>,
pub name: String,
pub parent_ident_id: Option<i64>,
pub publisher: Option<String>,
diff --git a/rust/src/lib.rs b/rust/src/lib.rs
index 196dee36..49d0ef70 100644
--- a/rust/src/lib.rs
+++ b/rust/src/lib.rs
@@ -13,6 +13,7 @@ extern crate hyper;
extern crate error_chain;
extern crate iron;
extern crate r2d2;
+extern crate serde_json;
pub mod api_server;
pub mod database_schema;