Skip to content

Commit

Permalink
Updated all crates (#709)
Browse files Browse the repository at this point in the history
removed the deprecated mod "Attribute_value"
added serde_dynamo "to_attribute_value"
updated the code to match the new changes
#708
  • Loading branch information
sebmaz93 authored Oct 23, 2023
1 parent 2675fa9 commit b9d64e8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
17 changes: 9 additions & 8 deletions examples/http-dynamodb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ edition = "2021"
# and it will keep the alphabetic ordering for you.

[dependencies]
simple-error = "0.2.3"
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
simple-error = "0.3.0"
serde_json = "1.0.107"
serde = { version = "1.0.189", features = ["derive"] }
serde_dynamo = {version = "^4.2.7", features = ["aws-sdk-dynamodb+0_33"]}
lambda_http = { path = "../../lambda-http" }
lambda_runtime = { path = "../../lambda-runtime" }
aws-sdk-dynamodb = "0.21.0"
aws-config = "0.51.0"
tokio = { version = "1", features = ["macros"] }
tracing = { version = "0.1", features = ["log"] }
tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt"] }
aws-sdk-dynamodb = "0.33.0"
aws-config = "0.56.1"
tokio = { version = "1.33.0", features = ["macros"] }
tracing = { version = "0.1.40", features = ["log"] }
tracing-subscriber = { version = "0.3.17", default-features = false, features = ["fmt"] }


19 changes: 10 additions & 9 deletions examples/http-dynamodb/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use aws_sdk_dynamodb::model::AttributeValue;
use aws_sdk_dynamodb::{Client, Error as OtherError};
use aws_sdk_dynamodb::{Client};
use lambda_http::{run, service_fn, Body, Error, Request, Response};
use serde::{Deserialize, Serialize};
use serde_dynamo::to_attribute_value;
use tracing::info;

#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Item {
pub p_type: String,
pub age: String,
Expand Down Expand Up @@ -76,12 +77,12 @@ async fn main() -> Result<(), Error> {

// Add an item to a table.
// snippet-start:[dynamodb.rust.add-item]
pub async fn add_item(client: &Client, item: Item, table: &str) -> Result<(), OtherError> {
let user_av = AttributeValue::S(item.username);
let type_av = AttributeValue::S(item.p_type);
let age_av = AttributeValue::S(item.age);
let first_av = AttributeValue::S(item.first);
let last_av = AttributeValue::S(item.last);
pub async fn add_item(client: &Client, item: Item, table: &str) -> Result<(), Error> {
let user_av = to_attribute_value(item.username)?;
let type_av = to_attribute_value(item.p_type)?;
let age_av = to_attribute_value(item.age)?;
let first_av = to_attribute_value(item.first)?;
let last_av = to_attribute_value(item.last)?;

let request = client
.put_item()
Expand Down

0 comments on commit b9d64e8

Please sign in to comment.