/query returns map with hashes

feat/vaults
Tomáš Mládek 2021-02-21 12:30:17 +01:00
parent c0c240256a
commit 302f435c5d
1 changed files with 9 additions and 2 deletions

View File

@ -60,9 +60,16 @@ pub async fn get_query(
let sexp = lexpr::from_str(info.query.as_str()).map_err(ErrorBadRequest)?;
let in_query = Query::try_from(&sexp).map_err(ErrorBadRequest)?;
let result = query(&connection, in_query).map_err(ErrorInternalServerError)?;
let entries = query(&connection, in_query).map_err(ErrorInternalServerError)?;
let mut result: HashMap<String, Entry> = HashMap::new();
for entry in entries {
result.insert(
encode(entry.hash().map_err(ErrorInternalServerError)?),
entry,
);
}
Ok(HttpResponse::Ok().json(result))
Ok(HttpResponse::Ok().json(&result))
}
#[get("/api/obj/{address_str}")]