refactor: file_info

This commit is contained in:
Per Stark
2024-12-09 21:18:03 +01:00
parent b61dae1ea8
commit 6ad4071d63
3 changed files with 114 additions and 360 deletions
+15
View File
@@ -98,3 +98,18 @@ where
{
db_client.select(T::table_name()).await
}
/// Operation to retrieve a single object by its ID, requires the struct to implement StoredObject
///
/// # Arguments
/// * `db_client` - An initialized database client
/// * `id` - The ID of the item to retrieve
///
/// # Returns
/// * `Result<Option<T>, Error>` - The found item or Error
pub async fn get_item<T>(db_client: &Surreal<Client>, id: &str) -> Result<Option<T>, Error>
where
T: for<'de> StoredObject,
{
Ok(db_client.select((T::table_name(), id)).await?)
}