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

139
Views
UpdateExpression para aplanar el registro

Tengo tales elementos en Dynamo DB:

 [{ "Id": "1", "Data": { "Value": "test" } }, { "Id": "2", "Data": {} }, { "Id": "3" }, { "Id": "4", "Data": { "Wrong": "234" } }]

Y estoy tratando de aplanarlo, pero solo para el campo Data.Value :

 [{ "Id": "1", "Value": "test" }, { "Id": "2" }, { "Id": "3" }, { "Id": "4" }]

Mi solicitud de actualización se ve así:

 var request = new UpdateItemRequest { TableName = "<table>", Key = new Dictionary<string, AttributeValue> {{"Id", new AttributeValue("<item-id>")}}, UpdateExpression = "SET #a = #c.#a REMOVE #c", ExpressionAttributeNames = new Dictionary<string, string> { {"#c", "Data"}, {"#a", "Value"} } };

Esto funciona bien para Id = 1 y 3. Pero no funciona para 2 y 4. Supongo que porque no puede hacer un SET. No arroja ningún error, simplemente no elimina el atributo Data .

¿Hay alguna manera de hacerlo en una sola llamada?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

solo necesita una condición con su expresión, para verificar si el atributo existe o no, eso es todo.

 ConditionExpression ="attribute_exists (#c.#a)"

Para más detalles en Amazon doncs aquí .

over 4 years ago · Santiago Trujillo 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!