pub struct StorageMetadataRepo { /* private fields */ }Expand description
Storage metadata repository backed by PostgreSQL.
Implementations§
Source§impl StorageMetadataRepo
impl StorageMetadataRepo
Sourcepub const fn new(pool: PgPool) -> Self
pub const fn new(pool: PgPool) -> Self
Create a new repository wrapping the given connection pool.
Sourcepub async fn insert(&self, row: &NewStorageObject) -> Result<i64, FraiseQLError>
pub async fn insert(&self, row: &NewStorageObject) -> Result<i64, FraiseQLError>
Insert a new object metadata row, returning the generated primary key.
§Errors
Returns FraiseQLError::File if the database query fails
(e.g. duplicate (bucket, key) pair).
Sourcepub async fn get(
&self,
bucket: &str,
key: &str,
) -> Result<Option<StorageMetadataRow>, FraiseQLError>
pub async fn get( &self, bucket: &str, key: &str, ) -> Result<Option<StorageMetadataRow>, FraiseQLError>
Look up an object by bucket and key.
§Errors
Returns FraiseQLError::File if the database query fails.
Sourcepub async fn delete(
&self,
bucket: &str,
key: &str,
) -> Result<bool, FraiseQLError>
pub async fn delete( &self, bucket: &str, key: &str, ) -> Result<bool, FraiseQLError>
Delete an object metadata row by bucket and key.
Returns true if a row was actually deleted, false if no matching row existed.
§Errors
Returns FraiseQLError::File if the database query fails.
Sourcepub async fn list(
&self,
bucket: &str,
prefix: Option<&str>,
limit: u32,
offset: u32,
) -> Result<Vec<StorageMetadataRow>, FraiseQLError>
pub async fn list( &self, bucket: &str, prefix: Option<&str>, limit: u32, offset: u32, ) -> Result<Vec<StorageMetadataRow>, FraiseQLError>
List objects in a bucket, optionally filtered by key prefix.
Results are ordered by key ascending. Use limit and offset for pagination.
§Errors
Returns FraiseQLError::File if the database query fails.
Sourcepub async fn upsert(&self, row: &NewStorageObject) -> Result<i64, FraiseQLError>
pub async fn upsert(&self, row: &NewStorageObject) -> Result<i64, FraiseQLError>
Insert or update an object metadata row (upsert on (bucket, key)).
On conflict, updates content_type, size_bytes, etag, and updated_at.
§Errors
Returns FraiseQLError::File if the database query fails.
Auto Trait Implementations§
impl Freeze for StorageMetadataRepo
impl !RefUnwindSafe for StorageMetadataRepo
impl Send for StorageMetadataRepo
impl Sync for StorageMetadataRepo
impl Unpin for StorageMetadataRepo
impl UnsafeUnpin for StorageMetadataRepo
impl !UnwindSafe for StorageMetadataRepo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more