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

Searching for values within an array using the ".includes" method

I'm curious if there's a method to determine if a string contains any characters that are also present in an array? const array = ["cake", "hello", "ok"]; const string = "hello"; let result = string.include ...

Using Jquery to insert content into HTML using the .html() method is not possible

I am inserting Dynamic Code into a Div via Ajax and I also need to include some Javascript, but it's not displaying in the code. Below is the code snippet: $.ajax({ url: "ajax_add_logo_parts.php", data: 'act=getPartIm ...

Can a new frame be created below an already existing frame in HTML?

My main.html file looks like this: ----- main.html---------------- <title>UniqueTrail</title> <script src="main.js"></script> <frameset rows='200,200'> <frame id='one' src="f ...

Problem with targeting the .prev() and closest() class of a text input box

Could you please review This Demo and advise why I am unable to select the first .fa class before the text box #name ? This is what I have been trying: $(this).prev().closest(".fa").addClass("err"); within this code block <div class="row"> & ...

What could be causing my externally hosted React component to malfunction when being imported via NPM?

After successfully creating a standalone component within my original project, I decided to explore the possibility of releasing it as an NPM module. To kick off this process, I attempted to load the library from another repository using NPM in a new proje ...

Iterate through a directory on the local machine and generate elements dynamically

I am looking to create a jQuery-UI tabs menu that includes 54 images on each tab. I have a total of 880 images stored in a folder, and it would be very time-consuming to manually insert an <img> tag for each one. Is there a way to dynamically cycle t ...

implementing multiple updates in Mongoose for MongoDB

There are often times when I need to make multiple update requests based on various conditions. if (some true condition) { let recordBeforeUpdate = await this.PatchModel.findOneAndUpdate({ "_id": patchId }, { $inc: { inStockPallets: -1, f ...

Function that returns an array

Hey there, wondering about variable scope in closures! I've come across a lot of questions on this topic but haven't found the solution to my issue. Here's the code snippet: var teams = []; var players = []; var getRoles = function(roleL ...

HTML5 input type Color displays individual RGB values

This code snippet opens up a variety of options for the user to manipulate different color values such as R, G, B, HEX VALUE, HUE, etc. However, the specific requirement is to only extract the Red value. <input id="color_pick"type="color" value="#ff0 ...

Exploring data visualization within a JSX Component

I am attempting to dynamically render a Card component that is mapped from an array of objects. However, I am encountering an "unexpected token error" and the URL is not rendering as expected. The goal is to display five cards based on the data within the ...

Responsive Tabs with Material-UI

Can MUI's Tabs be made responsive? This is what I currently have: https://i.stack.imgur.com/KF8eO.png And this is what I aim to accomplish: https://i.stack.imgur.com/b3QLc.png ...

Jquery Triggers Failing to Work Following Ajax Request

I have worked on 2 PHP pages, called "booking.php" and "fetch_book_time.php". Within my booking.php (where the jquery trigger is) <?php include ("conn.php"); include ("functions.php"); ?> $(document).ready(function(){ $(".form-group"). ...

Why are @Inject and Injectable important in Angular's Dependency Injection system?

constructor(private smartphoneService: smartphoneService) { } Although I am able to execute the code above without encountering any errors, I find myself pondering on the necessity of using @Inject and Injectable on services, Pipes, and other components. ...

Running two blocks of scripts (utilizing lab.js as a loading manager)

I am currently facing an issue where I am trying to load two separate blocks of `lab.js` in different locations. However, when I attempt to utilize functions from the second block that are called from files loaded in the first block, they are showing as un ...

Troubleshooting: Why is Jquery unable to retrieve image height?

Having trouble using jQuery to find the actual height of the first image nested within a container. I can access the src attribute but not the height. Any suggestions on how to get the accurate height? Is it necessary to retrieve heights via CSS? Unfortu ...

To compare two JSON files that contain identical values but different keys in order to generate a consolidated table

My goal is to create a comprehensive table by merging data from two different JSON files. One file contains names, work positions, and ages, while the other file includes emails, names, and job roles. The challenge lies in the fact that they use different ...

Understanding how to utilize and manipulate this JSON data using JavaScript

In my code, there is a variable that contains the following data: { "Rows": [ { "New":1, "CachedNumberType":0, "Date":1327479615921, "Type":2, "Number":"123456", "Duration ...

Is it acceptable to debut a full-screen iframe widget compared to an embedded one?

My current project involves integrating a custom widget into users' websites for my application. I am considering using an iframe as it seems to be the most efficient option for several reasons: Utilizing the custom framework of the application will ...

Using placeholders with inputs in an Angular2 table generated by ngFor

I have an array public example = [['hallo', 'fruit', 'rose'], ['apple','book']] Currently, I am working on creating a table of inputs. The values in this table depend on the specific part that I am usin ...

Can a function be activated in JavaScript when location permission is declined?

Background: Following up on a previous question regarding the use of getCurrentPosition and async functions. I am currently working on The Odin Project and attempting to create a basic weather application. My goal is to include a feature that automatically ...