diff --git a/meilidb-core/src/store/main.rs b/meilidb-core/src/store/main.rs index d35189ea9..55d5f10b0 100644 --- a/meilidb-core/src/store/main.rs +++ b/meilidb-core/src/store/main.rs @@ -13,6 +13,7 @@ const RANKED_MAP_KEY: &str = "ranked-map"; const SCHEMA_KEY: &str = "schema"; const STOP_WORDS_KEY: &str = "stop-words"; const SYNONYMS_KEY: &str = "synonyms"; +const UPDATED_AT: &str = "updated-at"; const WORDS_KEY: &str = "words"; type SerdeDatetime = SerdeBincode>; @@ -43,6 +44,14 @@ impl Main { self.main.put::(writer, CREATED_AT, &Utc::now()) } + pub fn updated_at(self, reader: &heed::RoTxn) -> ZResult>> { + self.main.get::(reader, UPDATED_AT) + } + + pub fn put_updated_at(self, writer: &mut heed::RwTxn) -> ZResult<()> { + self.main.put::(writer, UPDATED_AT, &Utc::now()) + } + pub fn put_words_fst(self, writer: &mut heed::RwTxn, fst: &fst::Set) -> ZResult<()> { let bytes = fst.as_fst().as_bytes(); self.main.put::(writer, WORDS_KEY, bytes) diff --git a/meilidb-http/src/routes/index.rs b/meilidb-http/src/routes/index.rs index 53b9f36e5..af0e15a70 100644 --- a/meilidb-http/src/routes/index.rs +++ b/meilidb-http/src/routes/index.rs @@ -102,6 +102,8 @@ pub async fn create_index(mut ctx: Context) -> SResult { .put_created_at(&mut writer) .map_err(ResponseError::internal)?; created_index.main + .put_updated_at(&mut writer) + .map_err(ResponseError::internal)?; let schema: Option = body.schema.clone().map(|s| s.into()); let mut response_update_id = None;