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

326
Visualizações
How to update map property in dynamodb

I have a map in dynamo with the following structure:

 participants: {
      M: {
        "6ecd8c99-4036-403d-bf84-cf8400f67836": {
          M: {
            participantUid: {
              S: "6ecd8c99-4036-403d-bf84-cf8400f67836",
            },
            userSummary: {
              M: {
                userRef: {
                  S: "refGoesHere",
                },
              },
            },
            isRead: {
              BOOL: false,
            },
          },
        },
      },
    },

I'm trying to update the isRead property with the following command:

const updateReadStatusCommand = new UpdateCommand({
      TableName: config.database,
      Key: {
        PK: `TASK#${taskUid}#CLIENT#${client}`,
        SK: `THREAD#${uid}`,
      },
      UpdateExpression: `SET participants.#participantUid.isRead = :isRead`,
      ExpressionAttributeNames: {
        "#participantUid": userUid,
      },
      ExpressionAttributeValues: {
        ":isRead": updateBody.isRead,
      },
      ReturnValues: "ALL_NEW",
    });

So far I keep running into the following error: The document path provided in the update expression is invalid for update.

I'm struggling to see the issue here, as it won't recognise the property within the map. Can anyone point me in the right direction?

Edit:

I've also scanned the table to ensure that the data is in the correct format and it looks like this:

"participants": {
        "6ecd8c99-4036-403d-bf84-cf8400f67836": {
          "isRead": false,
          "participantUid": "6ecd8c99-4036-403d-bf84-cf8400f67836",
          "userSummary": {
            "userRef": "refGoesHere"
          }
        }
      },
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I dont see much wrong with this, the only thing I can think of it trying to change -

UpdateExpression: `SET participants.#participantUid.isRead = :isRead`,
ExpressionAttributeNames: {
   "#participantUid": userUid,
},
...

to

UpdateExpression: `SET participants.#participantUid.#isRead = :isRead`,
ExpressionAttributeNames: {
   "#participantUid": userUid,
   "#isRead": "isRead"
},
...

in case .isRead is being treated as a string, rather than part of the path, as I noticed in the docs, like the example below, the use of #3str being used as #pr.#3star rather than using #pr.ThreeStar directly -

aws dynamodb update-item \
    --table-name ProductCatalog \
    --key '{"Id":{"N":"789"}}' \
    --update-expression "SET #pr.#5star[1] = :r5, #pr.#3star = :r3" \
    --expression-attribute-names file://names.json \
    --expression-attribute-values file://values.json \
    --return-values ALL_NEW

(names.json)

{
    "#pr": "ProductReviews",
    "#5star": "FiveStar",
    "#3star": "ThreeStar"
}
about 4 years ago · Juan Pablo Isaza Relatório

0

Solved this due to an incorrect SK which meant that the document I wanted to update couldn't be found.

The query itself was correct. Leaving this here for anyone in a similar position, check you're actually trying to update the right thing!

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