Currently, I am utilizing a transactWrite
instruction to interact with DynamoDb and I am expecting to receive the ItemCollectionMetrics
. Even though changes have been made on the DynamoDb tables, the returned object is empty with {}
.
Does anyone have any insights or suggestions regarding this issue?
Code Snippet
const dynamoResponse = await dynamoDbDocumentClient.transactWrite({
TransactItems: [
{
Put: {
TableName: ENV.BLAH_CONTENT_COUNT_MESSAGES_TABLE,
ExpressionAttributeNames : {
'#v' : 'v',
},
ExpressionAttributeValues : {
':v' : blah.v
},
ConditionExpression: '(attribute_exists(blahId) AND #v<>:v) OR attribute_not_exists(blahId)',
Item: {...blahCountMessage}
}
},
{
Update: {
TableName: ENV.BLAH_CONTENT_COUNTS_TABLE,
Key: { id: blahContentCount.id },
ExpressionAttributeNames : {
'#v' : 'v',
'#count' : 'count',
'#contentId': 'contentId'
},
ExpressionAttributeValues : {
':v' : 1,
':count' : deleted ? -1: 1,
':contentId': blahContentCount.contentId,
':defaultNumber': 0
},
ConditionExpression: 'attribute_not_exists(cognitoId)',
UpdateExpression: 'SET #contentId = :contentId, #count = if_not_exists(#count, :defaultNumber) + :count, #v = if_not_exists(#v, :defaultNumber) + :v',
ReturnValuesOnConditionCheckFailure: 'ALL_OLD'
}
}
],
ReturnItemCollectionMetrics: 'SIZE'
}).promise();
Output
console.log(JSON.stringify(dynamoResponse.ItemCollectionMetrics)); // {}
Thank you for any assistance!