diff --git a/services/backup/src/database/mod.rs b/services/backup/src/database/mod.rs
index 1483d1c9b..0a6408cef 100644
--- a/services/backup/src/database/mod.rs
+++ b/services/backup/src/database/mod.rs
@@ -1,282 +1,366 @@
pub mod backup_item;
pub mod log_item;
use std::collections::HashMap;
use aws_sdk_dynamodb::{
- operation::get_item::GetItemOutput, types::AttributeValue,
+ operation::get_item::GetItemOutput,
+ types::{AttributeValue, ReturnValue},
};
use comm_services_lib::database::Error;
-use tracing::error;
+use tracing::{error, trace, warn};
use crate::constants::{
BACKUP_TABLE_FIELD_BACKUP_ID, BACKUP_TABLE_FIELD_USER_ID,
BACKUP_TABLE_INDEX_USERID_CREATED, BACKUP_TABLE_NAME,
LOG_TABLE_FIELD_ATTACHMENT_HOLDERS, LOG_TABLE_FIELD_BACKUP_ID,
LOG_TABLE_FIELD_DATA_HASH, LOG_TABLE_FIELD_LOG_ID,
LOG_TABLE_FIELD_PERSISTED_IN_BLOB, LOG_TABLE_FIELD_VALUE, LOG_TABLE_NAME,
};
use self::{
backup_item::{BackupItem, OrderedBackupItem},
log_item::{parse_log_item, LogItem},
};
#[derive(Clone)]
pub struct DatabaseClient {
client: aws_sdk_dynamodb::Client,
}
impl DatabaseClient {
pub fn new(aws_config: &aws_types::SdkConfig) -> Self {
DatabaseClient {
client: aws_sdk_dynamodb::Client::new(aws_config),
}
}
// backup item
pub async fn put_backup_item(
&self,
backup_item: BackupItem,
) -> Result<(), Error> {
let item = backup_item.into();
self
.client
.put_item()
.table_name(BACKUP_TABLE_NAME)
.set_item(Some(item))
.send()
.await
.map_err(|e| {
error!("DynamoDB client failed to put backup item");
Error::AwsSdk(e.into())
})?;
Ok(())
}
pub async fn find_backup_item(
&self,
user_id: &str,
backup_id: &str,
) -> Result