mirror of
https://github.com/perstarkse/minne.git
synced 2026-03-23 09:51:36 +01:00
helper functions
This commit is contained in:
@@ -5,6 +5,8 @@ use surrealdb::{
|
||||
Error, Surreal,
|
||||
};
|
||||
|
||||
use crate::storage::types::StoredObject;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SurrealDbClient {
|
||||
pub client: Surreal<Client>,
|
||||
@@ -32,6 +34,24 @@ impl SurrealDbClient {
|
||||
|
||||
Ok(SurrealDbClient { client: db })
|
||||
}
|
||||
|
||||
pub async fn rebuild_indexes(&self) -> Result<(), Error> {
|
||||
self.client
|
||||
.query("REBUILD INDEX IF EXISTS idx_embedding ON text_chunk")
|
||||
.await?;
|
||||
self.client
|
||||
.query("REBUILD INDEX IF EXISTS embeddings ON knowledge_entity")
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn drop_table<T>(&self) -> Result<(), Error>
|
||||
where
|
||||
T: StoredObject + Send + Sync + 'static,
|
||||
{
|
||||
let _deleted: Vec<T> = self.client.delete(T::table_name()).await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for SurrealDbClient {
|
||||
|
||||
Reference in New Issue
Block a user