0
votes

This seems like it should be really simple but I haven't found any examples or documentation. I've got a dynamodb table that looks like this:

record 1: {name, email, items[{product}, {item2}, {item3]}

record 2: (name, email, items[{product}, {item2}, {item3]}

I need to be able to update items elements, i.e., update item1 object in record 1. I can do this with the following code by hardcoding the list array element, but I can't figure out how to pass the item number into the update expression :

{
"version" : "2017-02-28",
"operation" : "UpdateItem",
"key" : {
    "id" : { "S" : "${context.arguments.input.id}" }
},
"update" : {
    "expression" : "SET #items[0].#product= :productVal",
    "expressionNames" : {
        "#product": "product",
    },
    "expressionValues" : {
        ":productVal": { "S" : "${context.arguments.input.product}" },
    }
}
1

1 Answers

0
votes

Have you tried something like:

"update" : {
    "expression" : "SET #items[:idx].#product= :productVal",
    "expressionNames" : {
        "#product": "product",
    },
    "expressionValues" : {
        ":productVal": { "S" : "${context.arguments.input.product}" },
        ":idx": { "N" : 0 }
    }
}