mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-23 05:14:27 +01:00
review fixes
This commit is contained in:
parent
f18e795124
commit
ed44e684cc
@ -192,7 +192,7 @@ impl IndexStore {
|
||||
Ok((index, update_store))
|
||||
}
|
||||
|
||||
/// Same a get or create, but returns an error if the index already exists.
|
||||
/// Same as `get_or_create`, but returns an error if the index already exists.
|
||||
pub fn create_index(
|
||||
&self,
|
||||
name: impl AsRef<str>,
|
||||
@ -219,23 +219,17 @@ impl IndexStore {
|
||||
/// Returns each index associated with it's metadata;
|
||||
pub fn list_indexes(&self) -> anyhow::Result<Vec<(String, IndexMeta)>> {
|
||||
let txn = self.env.read_txn()?;
|
||||
let indexes = self.name_to_uuid
|
||||
let metas = self.name_to_uuid
|
||||
.iter(&txn)?
|
||||
.filter_map(|entry| entry
|
||||
.map_err(|e| {
|
||||
error!("error decoding entry while listing indexes: {}", e);
|
||||
e
|
||||
})
|
||||
.ok())
|
||||
.map(|(name, uuid)| {
|
||||
.map_err(|e| { error!("error decoding entry while listing indexes: {}", e); e }).ok());
|
||||
let mut indexes = Vec::new();
|
||||
for (name, uuid) in metas {
|
||||
let meta = self.uuid_to_index_meta
|
||||
.get(&txn, &uuid)
|
||||
.ok()
|
||||
.flatten()
|
||||
.get(&txn, &uuid)?
|
||||
.unwrap_or_else(|| panic!("corrupted database, index {} should exist.", name));
|
||||
(name.to_owned(), meta)
|
||||
})
|
||||
.collect();
|
||||
indexes.push((name.to_owned(), meta));
|
||||
}
|
||||
Ok(indexes)
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ pub struct IndexMetadata {
|
||||
uuid: Uuid,
|
||||
created_at: DateTime<Utc>,
|
||||
updated_at: DateTime<Utc>,
|
||||
pub primary_key: Option<String>,
|
||||
primary_key: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
Loading…
Reference in New Issue
Block a user