Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

109
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda