Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

107
Views
Javascript Trasnact Write failing on increment item

I am trying to do a transact write in DynamoDB. I can't seem to see the error and the error says "validationError, none" which isn't particualarly helpful. The Put for sure works but I am keeping here for completeness in the example

    await dynamoDb.transactWrite({
      TransactItems: [
        {
          Put: {
            TableName: process.env.TABLE_NAME,
            Item: {
              pk: compoundId,
              sk: interest,
              gsi1pk: "#INTEREST",
              interest: interest,
              id,
            },
          },
        },
        {
          Update: {
            ExpressionAttributeValues: {
              ":num": 1,
              ":initial": 0,
            },
            ExpressionAttributeNames: {
              "#tally": "tally",
            },
            Key: {
              PK: shop,
              SK: interest,
            },
            TableName: process.env.TABLE_NAME,
            UpdateExpression:
              "SET #tally = if_not_exists(tally, :initial) + :num",
          },
        },
      ],
    });

I'm fairly confident that this is doable per these similar solved questions here:

ItemCollectionMetrics is empty after successful transactWrite using DynamoDB.DocumentClient

Increment the value if it exists, else add a new entry in DynamoDB

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The following appears to have worked and the error was adding the ExpressionAttributeNames

    await dynamoDb.transactWrite({
      TransactItems: [
        {
          Put: {
            TableName: process.env.TABLE_NAME,
            Item: {
              pk: compoundId,
              sk: interest,
              gsi1pk: "#INTEREST",
              watching: watching,
              interest: interest,
              id,
            },
          },
        },
        {
          Update: {
            ExpressionAttributeValues: {
              ":num": 1,
              ":initial": 0,
            },
            Key: {
              pk: shop,
              sk: interest,
            },
            TableName: process.env.TABLE_NAME,
            UpdateExpression:
              "SET tally = if_not_exists(tally, :initial) + :num",
          },
        },
      ],
    });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!