1回答
- 新しい順
- 投票が多い順
- コメントが多い順
1
I tested this in my own account and it works with no issue, returning the NEW_IMAGE in the response to ensure the update was successful:
const AWS = require('aws-sdk');
const dynamoDb = new AWS.DynamoDB({region: 'eu-west-1'});
var hID = "24cf6015-780e-408d-b0e1-935ae2c7199d";
var params = {
TableName: "cust1",
Key: {
pk: { "S": "123" },
sk: { "S": "abc" }
},
UpdateExpression: "SET #hp.#id.#a = :a",
ExpressionAttributeValues: { ":a": { "N": "0" } },
ExpressionAttributeNames: { "#hp": "hedge_positions", "#id": hID, "#a": "active" },
ReturnValues: "ALL_NEW"
};
dynamoDb.updateItem(params)
.promise()
.then(res=>console.log(JSON.stringify(res)))
.catch(err=>console.log(err));
Item before:
{
"pk": "123",
"sk": "abc",
"active": 1,
"delta": -0.9371997798455771,
"dte": 0.01893752246685426,
"hedge_positions": {
"151e9c9f-aa5d-4f5d-9826-74011da03137": {
"active": 1
},
"1bed59c9-6f73-48ae-8b65-62fd1f10ddad": {
"active": 1
},
"24cf6015-780e-408d-b0e1-935ae2c7199d": {
"active": 1
}
}
}
Item After:
{
"pk": "123",
"sk": "abc",
"active": 1,
"delta": -0.9371997798455771,
"dte": 0.01893752246685426,
"hedge_positions": {
"151e9c9f-aa5d-4f5d-9826-74011da03137": {
"active": 1
},
"1bed59c9-6f73-48ae-8b65-62fd1f10ddad": {
"active": 1
},
"24cf6015-780e-408d-b0e1-935ae2c7199d": {
"active": 0
}
}
}
関連するコンテンツ
- AWS公式更新しました 8ヶ月前
- AWS公式更新しました 2年前
- AWS公式更新しました 2年前