Skip to content

Commit

Permalink
suggest: Support clearing the suggestions store.
Browse files Browse the repository at this point in the history
This commit exposes `SuggestDb.clear()` as `SuggestStore.clear()`, and
ensures that it removes all icons in addition to suggestions and
metadata.
  • Loading branch information
linabutler committed Jul 14, 2023
1 parent 541d2ca commit b64c945
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions components/suggest/src/db.rs
Expand Up @@ -212,9 +212,11 @@ impl SuggestDb {
Ok(())
}

/// Clears the database, removing all suggestions, icons, and metadata.
pub fn clear(&self) -> Result<()> {
self.conn.lock().unwrap().execute_batch(
"DELETE FROM suggestions;
DELETE FROM icons;
DELETE FROM meta;",
)?;
Ok(())
Expand Down
5 changes: 5 additions & 0 deletions components/suggest/src/store.rs
Expand Up @@ -202,6 +202,11 @@ impl SuggestStore {

Ok(())
}

pub fn clear(&self) -> Result<(), SuggestApiError> {
let writer = &self.dbs()?.writer;
Ok(writer.clear()?)
}
}

struct SuggestStoreDbs {
Expand Down
3 changes: 3 additions & 0 deletions components/suggest/src/suggest.udl
Expand Up @@ -44,4 +44,7 @@ interface SuggestStore {

[Throws=SuggestApiError]
void ingest([ByRef] IngestLimits limits);

[Throws=SuggestApiError]
void clear();
};

0 comments on commit b64c945

Please sign in to comment.