[][src]Macro dynamodb_data::fields

macro_rules! fields {
    ($($k:tt => $v:expr),* $(,)?) => { ... };
}

Converts the given fields to HashMap<String, AttributeValue>, automatically serializing the keys to AttributeValue VIA serde_json.

Example 1:

use dynamodb_data::*;
use std::collections::HashMap;
 
let payload: HashMap<String, rusoto_dynamodb::AttributeValue> = fields!{
    id => ::uuid::Uuid::new_v4(),
    name => "user name",
    counter => 0
};
 
// Str keys are also supported
let payload: HashMap<String, rusoto_dynamodb::AttributeValue> = fields!{
    "id" => ::uuid::Uuid::new_v4(),
    // `name` is a DynamoDB reserved word.
    ":name" => "user name",
    "counter" => 0,
    // Others can still be identifiers though
    some_other_field => 0
};

Example 2:

use dynamodb_data::*;
let get_item_query = rusoto_dynamodb::GetItemInput {
    key: fields!{
        id => ::uuid::Uuid::new_v4()
    },
    ..Default::default()
};