Skip to content
v2.278.0

DynamoAttributeValue Class ​

Represents the data for an attribute.

Each attribute value is described as a name-value pair. The name is the data type, and the value is the data itself.

Example ​

ts
declare const myTable: dynamodb.Table;
new tasks.DynamoDeleteItem(this, 'DeleteItem', {
  key: { MessageId: tasks.DynamoAttributeValue.fromString('message-007') },
  table: myTable,
  resultPath: sfn.JsonPath.DISCARD,
});
python
# my_table: dynamodb.Table

tasks.DynamoDeleteItem(self, "DeleteItem",
    key={"MessageId": tasks.DynamoAttributeValue.from_string("message-007")},
    table=my_table,
    result_path=sfn.JsonPath.DISCARD
)
java
Table myTable;

DynamoDeleteItem.Builder.create(this, "DeleteItem")
        .key(Map.of("MessageId", DynamoAttributeValue.fromString("message-007")))
        .table(myTable)
        .resultPath(JsonPath.DISCARD)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
Table myTable;

new DynamoDeleteItem(this, "DeleteItem", new DynamoDeleteItemProps {
    Key = new Dictionary<string, DynamoAttributeValue> { { "MessageId", DynamoAttributeValue.FromString("message-007") } },
    Table = myTable,
    ResultPath = JsonPath.DISCARD
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var myTable Table

tasks.NewDynamoDeleteItem(this, jsii.String("DeleteItem"), &DynamoDeleteItemProps{
	Key: map[string]DynamoAttributeValue{
		"MessageId": tasks.DynamoAttributeValue_fromString(jsii.String("message-007")),
	},
	Table: myTable,
	ResultPath: sfn.JsonPath_DISCARD(),
})

Properties ​

attributeValueanyattribute_valueAnyattributeValueObjectAttributeValueobjectAttributeValueinterface{} #
Represents the data for the attribute.

Data can be i.e. "S": "Hello"

Methods ​

booleanFromJsonata(value: string): DynamoAttributeValue // chainable@staticmethod def boolean_from_jsonata(value: str) -> DynamoAttributeValuepublic static DynamoAttributeValue booleanFromJsonata(String value)public static DynamoAttributeValue BooleanFromJsonata(string value)func BooleanFromJsonata(Value *string) DynamoAttributeValue static #
Sets an attribute of type Boolean from state input through JSONata expression.

For example: "BOOL": true

1 parameter

Parameters

  • valuevaluevaluevalueValue — JSONata expression that specifies state input to be used.
booleanFromJsonPath(value: string): DynamoAttributeValue // chainable@staticmethod def boolean_from_json_path(value: str) -> DynamoAttributeValuepublic static DynamoAttributeValue booleanFromJsonPath(String value)public static DynamoAttributeValue BooleanFromJsonPath(string value)func BooleanFromJsonPath(Value *string) DynamoAttributeValue static #
Sets an attribute of type Boolean from state input through Json path.

For example: "BOOL": true

1 parameter

Parameters

  • valuevaluevaluevalueValue — Json path that specifies state input to be used.
fromBinary(value: string): DynamoAttributeValue // chainable@staticmethod def from_binary(value: str) -> DynamoAttributeValuepublic static DynamoAttributeValue fromBinary(String value)public static DynamoAttributeValue FromBinary(string value)func FromBinary(Value *string) DynamoAttributeValue static #
Sets an attribute of type Binary.

For example: "B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk"

1 parameter

Parameters

  • valuevaluevaluevalueValue — base-64 encoded string.
fromBinarySet(value: string[]): DynamoAttributeValue // chainable@staticmethod def from_binary_set(value: typing.List[str]) -> DynamoAttributeValuepublic static DynamoAttributeValue fromBinarySet(List<String> value)public static DynamoAttributeValue FromBinarySet(string[] value)func FromBinarySet(Value *[]*string) DynamoAttributeValue static #
Sets an attribute of type Binary Set.

For example: "BS": ["U3Vubnk=", "UmFpbnk=", "U25vd3k="]

fromBoolean(value: boolean): DynamoAttributeValue // chainable@staticmethod def from_boolean(value: bool) -> DynamoAttributeValuepublic static DynamoAttributeValue fromBoolean(Boolean value)public static DynamoAttributeValue FromBoolean(bool value)func FromBoolean(Value *bool) DynamoAttributeValue static #
Sets an attribute of type Boolean.

For example: "BOOL": true

fromList(value: DynamoAttributeValue[]): DynamoAttributeValue // chainable@staticmethod def from_list(value: typing.List[DynamoAttributeValue]) -> DynamoAttributeValuepublic static DynamoAttributeValue fromList(List<DynamoAttributeValue> value)public static DynamoAttributeValue FromList(DynamoAttributeValue[] value)func FromList(Value *[]DynamoAttributeValue) DynamoAttributeValue static #
Sets an attribute of type List.

For example: "L": [ {"S": "Cookies"} , {"S": "Coffee"}, {"N", "3.14159"}]

fromMap(value: { [key: string]: DynamoAttributeValue }): DynamoAttributeValue // chainable@staticmethod def from_map(value: typing.Mapping[str, DynamoAttributeValue]) -> DynamoAttributeValuepublic static DynamoAttributeValue fromMap(Map<String, DynamoAttributeValue> value)public static DynamoAttributeValue FromMap(IDictionary<string, DynamoAttributeValue> value)func FromMap(Value *map[string]DynamoAttributeValue) DynamoAttributeValue static #
Sets an attribute of type Map.

For example: "M": {"Name": {"S": "Joe"}, "Age": {"N": "35"}}

fromNull(value: boolean): DynamoAttributeValue // chainable@staticmethod def from_null(value: bool) -> DynamoAttributeValuepublic static DynamoAttributeValue fromNull(Boolean value)public static DynamoAttributeValue FromNull(bool value)func FromNull(Value *bool) DynamoAttributeValue static #
Sets an attribute of type Null.

For example: "NULL": true

fromNumber(value: number): DynamoAttributeValue // chainable@staticmethod def from_number(value: int | float) -> DynamoAttributeValuepublic static DynamoAttributeValue fromNumber(Number value)public static DynamoAttributeValue FromNumber(double value)func FromNumber(Value *float64) DynamoAttributeValue static #
Sets a literal number.

For example: 1234 Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and libraries. However, DynamoDB treats them as number type attributes for mathematical operations.

fromNumberSet(value: number[]): DynamoAttributeValue // chainable@staticmethod def from_number_set(value: typing.List[int | float]) -> DynamoAttributeValuepublic static DynamoAttributeValue fromNumberSet(List<Number> value)public static DynamoAttributeValue FromNumberSet(double[] value)func FromNumberSet(Value *[]*float64) DynamoAttributeValue static #
Sets an attribute of type Number Set.
notes

For example: "NS": ["42.2", "-19", "7.5", "3.14"] Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and libraries. However, DynamoDB treats them as number type attributes for mathematical operations.

fromString(value: string): DynamoAttributeValue // chainable@staticmethod def from_string(value: str) -> DynamoAttributeValuepublic static DynamoAttributeValue fromString(String value)public static DynamoAttributeValue FromString(string value)func FromString(Value *string) DynamoAttributeValue static #
Sets an attribute of type String.
notes

For example: "S": "Hello" Strings may be literal values or as JSONata expression or as JsonPath. Example values:

  • DynamoAttributeValue.fromString('someValue')
  • DynamoAttributeValue.fromString('{% $bar %}')
  • DynamoAttributeValue.fromString(JsonPath.stringAt('$.bar'))
fromStringSet(value: string[]): DynamoAttributeValue // chainable@staticmethod def from_string_set(value: typing.List[str]) -> DynamoAttributeValuepublic static DynamoAttributeValue fromStringSet(List<String> value)public static DynamoAttributeValue FromStringSet(string[] value)func FromStringSet(Value *[]*string) DynamoAttributeValue static #
Sets an attribute of type String Set. For example: "SS": ["Giraffe", "Hippo" ,"Zebra"].

This method only accepts static arrays defined at CDK synthesis time. Dynamic value resolution via JSONata or JsonPath is not supported for Set types.

listFromJsonata(value: string): DynamoAttributeValue // chainable@staticmethod def list_from_jsonata(value: str) -> DynamoAttributeValuepublic static DynamoAttributeValue listFromJsonata(String value)public static DynamoAttributeValue ListFromJsonata(string value)func ListFromJsonata(Value *string) DynamoAttributeValue static #
Sets an attribute of type List.

For example: "L": [ {"S": "Cookies"} , {"S": "Coffee"}, {"S", "Veggies"}]

1 parameter

Parameters

  • valuevaluevaluevalueValue — JSONata expression that specifies state input to be used.
listFromJsonPath(value: string): DynamoAttributeValue // chainable@staticmethod def list_from_json_path(value: str) -> DynamoAttributeValuepublic static DynamoAttributeValue listFromJsonPath(String value)public static DynamoAttributeValue ListFromJsonPath(string value)func ListFromJsonPath(Value *string) DynamoAttributeValue static #
Sets an attribute of type List.

For example: "L": [ {"S": "Cookies"} , {"S": "Coffee"}, {"S", "Veggies"}]

1 parameter

Parameters

  • valuevaluevaluevalueValue — Json path that specifies state input to be used.
mapFromJsonata(value: string): DynamoAttributeValue // chainable@staticmethod def map_from_jsonata(value: str) -> DynamoAttributeValuepublic static DynamoAttributeValue mapFromJsonata(String value)public static DynamoAttributeValue MapFromJsonata(string value)func MapFromJsonata(Value *string) DynamoAttributeValue static #
Sets an attribute of type Map.

For example: "M": {"Name": {"S": "Joe"}, "Age": {"N": "35"}}

1 parameter

Parameters

  • valuevaluevaluevalueValue — JSONata expression that specifies state input to be used.
mapFromJsonPath(value: string): DynamoAttributeValue // chainable@staticmethod def map_from_json_path(value: str) -> DynamoAttributeValuepublic static DynamoAttributeValue mapFromJsonPath(String value)public static DynamoAttributeValue MapFromJsonPath(string value)func MapFromJsonPath(Value *string) DynamoAttributeValue static #
Sets an attribute of type Map.

For example: "M": {"Name": {"S": "Joe"}, "Age": {"N": "35"}}

1 parameter

Parameters

  • valuevaluevaluevalueValue — Json path that specifies state input to be used.
numberFromString(value: string): DynamoAttributeValue // chainable@staticmethod def number_from_string(value: str) -> DynamoAttributeValuepublic static DynamoAttributeValue numberFromString(String value)public static DynamoAttributeValue NumberFromString(string value)func NumberFromString(Value *string) DynamoAttributeValue static #
Sets an attribute of type Number.
notes

For example: "N": "123.45" Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and libraries. However, DynamoDB treats them as number type attributes for mathematical operations.

Numbers may be expressed as literal strings or as JSONata expression or as JsonPath

numberSetFromStrings(value: string[]): DynamoAttributeValue // chainable@staticmethod def number_set_from_strings(value: typing.List[str]) -> DynamoAttributeValuepublic static DynamoAttributeValue numberSetFromStrings(List<String> value)public static DynamoAttributeValue NumberSetFromStrings(string[] value)func NumberSetFromStrings(Value *[]*string) DynamoAttributeValue static #
Sets an attribute of type Number Set.
notes

For example: "NS": ["42.2", "-19", "7.5", "3.14"] Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and libraries. However, DynamoDB treats them as number type attributes for mathematical operations.

Numbers may be expressed as literal strings or as JsonPath

toObject(): anydef to_object(self, ) -> Anypublic Object toObject()public object ToObject()func ToObject() interface{} #
Returns the DynamoDB attribute value.