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

325
Views
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 answers
Answer question

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 Report

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 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!