After a successful transactWrite operation using DynamoDB.DocumentClient, the ItemCollectionMetrics remains unpopulated

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!

Answer №1

RetrieveItemSetMetrics:

"Data regarding sets of items affected by the action, if any. ItemSetMetrics will only be provided upon request. If there are no local secondary indexes on the table, this data will not be included in the response."

According to: https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ItemSetMetrics.html

Is it possible that this operation is either inactive or you do not have a Local Secondary Index?

Note that the documentation specifies that transactions are not supported for "global tables", although it's unclear if they refer to a GSI... However, since I am not utilizing an LSI, it may explain why ItemSetMetrics are never included in the transaction response.

If you adjust your parameter object to include ReturnConsumedCapacity: 'TOTAL', the resulting object should appear as follows:

   [ { TableName: 'table_name',
       CapacityUnits: 8,
       WriteCapacityUnits: 8 } ] }


Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How can I convert text containing in Node.js and insert actual new lines instead of the character?

I'm trying to transform a text response by removing special characters like \n and turning them into actual new lines. The initial response contains special characters -----BEGIN MESSAGE----- v1.60 hQEMAwPgeMJUXSL5Bps+U3lC8tnc D8s2Aeb7UtryIRAB ...

Is it possible to pass an Array into a callback function in element-ui's el-autocomplete component?

I attempted to utilize the el-autocomplete tag in its simplest form: using an Array returned by a callback function (JSFiddle version). Vue.component('button-counter', { data: function() { return { selectdusers: [], user: &ap ...

Incorporating a classList.toggle into a snippet of code

button, p, h1, h2, h3, h4, h5, a{ /* Define specific elements to use "fantasy" font */ font-family: Tahoma; } #main_body{ margin: 0px auto; background-color: #dedede; } #top_body{ /* Remove margin for simplicity */ } #t ...

Numerous status buttons with a variety of background colors

There are 3 buttons on the order page: [New Order], [Processing], and [Completed]. When the processing button is clicked, the background of the button should change and the order status will be updated in the database. The [New Order] button will have a ...

Don't display div if database has certain value - Angular

Is there a way to determine if a specific value exists in a PostgreSQL database? If so, can I then hide an HTML element based on this information? Can CSS and JavaScript be used to hide elements, or is there another method that should be utilized for hidi ...

How can a static website incorporate a local image without the need for backend functionality?

I have a unique challenge with my static website. It is designed to display a local image from the user's computer without utilizing a traditional backend system. The website itself is hosted on a static file server, and all image processing must be d ...

Tips on incorporating a firebase object into your Angular application using $scope

As a beginner in coding, I would greatly appreciate a simple answer. I am attempting to treat a Firebase object as a JavaScript array for use in HTML via $scope. What is the most effective approach? Database: database Current code: var mainApp = angula ...

Reduce the size of a container element without using jquery

In my Angular application, I have structured the header as follows: -- Header -- -- Sub header -- -- Search Box -- -- Create and Search Button -- -- Scroll Div -- HTML: <h1> Header </h1> <h3> Sub header </h3> <div class="s ...

Is it possible to dynamically incorporate directives within an AngularJS application?

I'm attempting to utilize several custom directives within the Ionic framework. The dynamic structure is like <mydir-{{type}}, where {{type}} will be determined by services and scope variables, with possible values such as radio, checkbox, select, ...

Implementing Ajax functionality in MVC 3 to return a partial view

I wanted to express my gratitude for this invaluable site that has taught me so much. Currently, I am working on an MVC3 component where I need to populate a selectlist and upon user selection, load a partial view with the relevant data displayed. Everythi ...

The Javascript regex allows for the presence of positive and negative numbers, with the option of a single minus symbol

oninput="this.value = this.value.replace(/[^-0-9.]/g, '') This code snippet is utilized in my current project. However, there seems to be an issue where the input can contain more than one minus sign, as shown here: ---23 To address this p ...

Post request in limbo

Looking for a way to delay post requests in Angular before they are sent? I've tried using pipe(delay(xxx)) and setTimeout, but haven't had any luck. Any suggestions on how to solve this issue? ...

attempting to refine an array of objects using another array within it

I am currently filtering a group of objects in the following manner: [ { "Username":"00d9a7f4-0f0b-448b-91fc-fa5aef314d06", "Attributes":[ { "Name":"custom:organization", "Valu ...

What could be causing the failure of the update for this computed property in my Vue 3 application?

Currently, I am in the process of creating an audio player using Vue 3 and the Napster API. About the Project I have managed to make the vinyl rotate by utilizing a CSS keyframes-based animation paired with the computed property isSpinning. I intend for ...

Utilizing $index in AngularJS while iterating through ng-repeat items

Here is an example of an unordered list: <ul class="dropdown-menu inner" role="menu"> <li ng-repeat="availableAlphaName in availableAlphaNames" data-original-index="0" data-optgroup="1" class=""> <a tabindex="0" class="opt " st ...

A continuous jQuery method for updating select option values

I'm currently working on a form and using jQuery to make some alterations. The form consists of multiple select elements, and I want to change the value of the first option in each of them. However, as the form allows for dynamic addition of new selec ...

List item with React Material UI tooltip

click here for image preview Exploring the idea of incorporating a customized tooltip component using React Material UI. The goal is to leverage the tooltip, list item, and list components provided by React Material UI. I have experimented with utilizing ...

Examining the scroll-down feature button

I'm currently experimenting with a scroll down button on my website and I'm perplexed as to why it's not functioning properly. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" c ...

Using Ajax and jQuery to redirect a page with values in ASP.NET

I have two pages: Default.aspx and DetailView.aspx. My goal is to redirect from Default.aspx to DetailView.aspx using an AJAX call and pass a value as well. Although I have tried something, the function defined in the class is not being called. The functi ...

When utilizing Route.get() with an express app, an error occurred as a callback function was expected, but instead, an [

My health.js file contains the following code: var health = function(req, res, done) {}; health.prototype.endpoint = function(req, res, done) { let http_status = 200; console.log("--- Sending health endpoint status of %s", http_status); res.se ...