Skip to content

Commit

Permalink
Include version in row
Browse files Browse the repository at this point in the history
  • Loading branch information
vlinkz committed Mar 3, 2024
1 parent 6418f89 commit 4a6f1a3
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/ddb/batch_put.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,24 @@ use aws_sdk_dynamodb::{
use log::{error, info, trace};
use std::collections::HashMap;

pub async fn batch_store_put(client: &Client, store: &HashMap<String, Store>, table: &str) -> Result<()> {
pub async fn batch_store_put(
client: &Client,
store: &HashMap<String, Store>,
table: &str,
) -> Result<()> {
let ops = store
.iter()
.map(|(_, v)| {
WriteRequest::builder()
.set_put_request(Some(
PutRequest::builder()
.set_put_request(Some({
let mut putreq = PutRequest::builder()
.item("store", AttributeValue::S(v.store.clone()))
.item("attribute", AttributeValue::S(v.attribute.clone()))
.build()
.expect("Failed to build PutRequest"),
))
.item("attribute", AttributeValue::S(v.attribute.clone()));
if let Some(version) = &v.version {
putreq = putreq.item("version", AttributeValue::S(version.clone()));
}
putreq.build().expect("Failed to build PutRequest")
}))
.build()
})
.collect::<Vec<WriteRequest>>();
Expand Down

0 comments on commit 4a6f1a3

Please sign in to comment.