I’m wanting to store an array of objects in my DynamoDB table but I’m unsure of which data type I should be specifying.
For example, I’m getting an API response with data that looks like:
{
id: 123,
...
testResults: [
{
testID: 1,
results: [ {product: X, result: 'pass'}, {product: Y, result: 'pass'} ]
},
{
testID: 2,
results: [ {product: A, result: 'fail'}, {product: B, result: 'pass'} ]
}
]
}
I’m wanting to extract the testResults
and push them to my DynamoDB…
I initially thought of a Map, however looking at the example given… It looks more like a JSON that can accept an array as a value to a key in there rather than just an array.
Any suggestions?
You’re looking to store an array/list in DynamoDB, then use the List data type!
List
A list type attribute can store an ordered collection of values. Lists are enclosed in square brackets: [ … ]
A list is similar to a JSON array. There are no restrictions on the data types that can be stored in a list element, and the elements in a list element do not have to be of the same type.