stripping schema nulls from stems
This commit is contained in:
@ -8,10 +8,5 @@ pub struct Stem {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub relation: Option<String>,
|
||||
|
||||
// The actual database schema node mapping for
|
||||
// O(1) jump table execution for queryer.
|
||||
//
|
||||
// Automatically skipped from `jspg_stems()` JSON payload output.
|
||||
#[serde(skip)]
|
||||
pub schema: Arc<Schema>,
|
||||
}
|
||||
|
||||
21
src/lib.rs
21
src/lib.rs
@ -121,24 +121,11 @@ pub fn jspg_stems() -> JsonB {
|
||||
|
||||
match engine_opt {
|
||||
Some(engine) => {
|
||||
let mut result_arr = Vec::new();
|
||||
for (schema_name, stems_map) in &engine.database.stems {
|
||||
let mut stems_arr = Vec::new();
|
||||
for (path_key, stem_arc) in stems_map {
|
||||
stems_arr.push(serde_json::json!({
|
||||
"path": path_key,
|
||||
"type": stem_arc.r#type,
|
||||
"relation": stem_arc.relation
|
||||
}));
|
||||
}
|
||||
result_arr.push(serde_json::json!({
|
||||
"schema": schema_name,
|
||||
"stems": stems_arr
|
||||
}));
|
||||
}
|
||||
JsonB(serde_json::to_value(result_arr).unwrap_or(Value::Array(Vec::new())))
|
||||
let stems_json = serde_json::to_value(&engine.database.stems)
|
||||
.unwrap_or(serde_json::Value::Object(serde_json::Map::new()));
|
||||
JsonB(stems_json)
|
||||
}
|
||||
None => JsonB(Value::Array(Vec::new())),
|
||||
None => JsonB(serde_json::Value::Object(serde_json::Map::new())),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user