implement create index

This commit is contained in:
mpostma 2021-02-08 10:47:34 +01:00
parent ed44e684cc
commit ec047eefd2
No known key found for this signature in database
GPG key ID: CBC8A7C1D7A28C3A
5 changed files with 69 additions and 22 deletions

View file

@ -54,17 +54,25 @@ async fn get_index(
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
struct IndexCreateRequest {
name: Option<String>,
uid: Option<String>,
name: String,
primary_key: Option<String>,
}
#[post("/indexes", wrap = "Authentication::Private")]
async fn create_index(
_data: web::Data<Data>,
_body: web::Json<IndexCreateRequest>,
data: web::Data<Data>,
body: web::Json<IndexCreateRequest>,
) -> Result<HttpResponse, ResponseError> {
todo!()
match data.create_index(&body.name, body.primary_key.clone()) {
Ok(meta) => {
let json = serde_json::to_string(&meta).unwrap();
Ok(HttpResponse::Ok().body(json))
}
Err(e) => {
error!("error creating index: {}", e);
unimplemented!()
}
}
}
#[derive(Debug, Deserialize)]