DynamoDB includes a data type descriptor for each element in query response, as shown below:
"Item": {
"M" : {
"Age": {"N": "8"},
"Name": {"S": "Fido"},
"Vaccinations": {
"M": {
"Rabies": {
"L": [
{"S": "2009-03-17"},
{"S": "2011-09-21"},
{"S": "2014-07-08"}
]
},
"Distemper": {"S": "2015-10-13"}
}
}
}
}
I would like to strip all of these descriptors ("S", "L", "M", etc), so that it looks like the next example, before I JSON.stringify
the data.
"Item": {
"Age": "8",
"Name": "Fido",
"Vaccinations": {
"Rabies": [
"2009-03-17",
"2011-09-21",
"2014-07-08"
]
"Distemper": "2015-10-13"
}
}
Is there are standard (or recommended) method for doing this?
With the DynamoDB API, you use the DeleteItem action to delete data from a table, one item at a time. You must specify the item's primary key values. In addition to DeleteItem , Amazon DynamoDB supports a BatchWriteItem action for deleting multiple items at the same time.
One way you can remove any DynamoDB table record is via hard delete operations such as DeleteItem or BatchWriteItem with DeleteRequest. These delete operations have to be triggered by administrators or any user who has delete privilege.
Use the DynamoDB Encryption Client for client-side encryption, in which you encrypt your table data before you send it to DynamoDB. You may choose to do this based on your data's sensitivity and your application's security requirements. For more information, see Client-Side and Server-Side Encryption.
DynamoDB supports the Java Set , List , and Map collection types. The following table summarizes how these Java types map to the DynamoDB types.
They have a converter that you can use.
For instance, here is their example:
var data= {"Item": {
"Age": {"N": "8"},
"Name": {"S": "Fido"},
"Vaccinations": {
"M": {
"Rabies": {
"L": [
{"S": "2009-03-17"},
{"S": "2011-09-21"},
{"S": "2014-07-08"}
]
},
"Distemper": {"S": "2015-10-13"}
}
}}};
var marshalled = AWS.DynamoDB.Converter.unmarshall(data);
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/Converter.html
With sdk version 3 there are a marshall and unmarshall utilities
https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/modules/_aws_sdk_util_dynamodb.html
import { marshall, unmarshall } from '@aws-sdk/util-dynamodb';
try {
const data = await ddbClient.send(new GetItemCommand(configReadService.params));
return unmarshall(data.Item) as unknown as ConfigAssets;
} catch (e) {
console.log('Reading the configuration database failed ', e)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With