Set the indexes info in the create_index function

This commit is contained in:
Clément Renault 2019-12-19 10:32:17 +01:00
parent 11b684114d
commit d12ff15ee3
No known key found for this signature in database
GPG Key ID: 0151CDAB43460DAE
2 changed files with 7 additions and 11 deletions

View File

@ -236,9 +236,13 @@ impl Database {
let (sender, receiver) = crossbeam_channel::bounded(100);
let index = store::create(&self.env, &self.update_env, name, sender)?;
let mut writer = self.env.write_txn()?;
let mut writer = self.env.typed_write_txn::<MainT>()?;
self.indexes_store.put(&mut writer, name, &())?;
index.main.put_name(&mut writer, name)?;
index.main.put_created_at(&mut writer)?;
index.main.put_updated_at(&mut writer)?;
let env_clone = self.env.clone();
let update_env_clone = self.update_env.clone();
let index_clone = index.clone();

View File

@ -57,13 +57,13 @@ pub async fn list_indexes(ctx: Context<Data>) -> SResult<Response> {
.map_err(ResponseError::internal)?
.ok_or(ResponseError::internal("'updated_at' date not found"))?;
let index_reponse = IndexResponse {
let index_response = IndexResponse {
name,
uid: index_uid,
created_at,
updated_at,
};
response_body.push(index_reponse);
response_body.push(index_response);
}
None => error!(
"Index {} is referenced in the indexes list but cannot be found",
@ -171,14 +171,6 @@ pub async fn create_index(mut ctx: Context<Data>) -> SResult<Response> {
.main
.put_name(&mut writer, &body.name)
.map_err(ResponseError::internal)?;
created_index
.main
.put_created_at(&mut writer)
.map_err(ResponseError::internal)?;
created_index
.main
.put_updated_at(&mut writer)
.map_err(ResponseError::internal)?;
let schema: Option<Schema> = body.schema.clone().map(Into::into);
let mut response_update_id = None;