Search code examples
node.jsamazon-web-servicestransactionssdk

AWS SDK v3 TransactWriteItemsCommand TypeError: Cannot read property '0' of undefined


I am trying to use TransactWriteItemsCommand to work using the new AWS SDK V3 for NodeJS. Unfortunately I can't find an example and the docs are not really well documented yet.

This is my params object:

    {
        "TransactItems": [
            {
                "Update": {
                    "TableName": "boxes",
                    "Key": {
                        "id": "36"
                    },
                    "UpdateExpression": "set isOpen = :isOpen",
                    "ExpressionAttributeValues": {
                        ":isOpen": {
                            "BOOL": true
                        }
                    }
                }
            },
            {
                "Update": {
                    "TableName": "boxes",
                    "Key": {
                        "id": "33"
                    },
                    "UpdateExpression": "set isOpen = :isOpen",
                    "ExpressionAttributeValues": {
                        ":isOpen": {
                            "BOOL": true
                        }
                    }
                }
            }
        ]
    }

What I'm doing wrong? Any help would be appreciated!


Solution

  • Thanks to @flanamacca for the answer

    The problem is the format of the key because I'm not using DynamoDB JSON format.

       "Key": {
        "id": {"S": "36"}
       },