【发布时间】:2020-08-10 12:14:22
【问题描述】:
我有存储在 dynamodb 中的地图结构,我想在学校对象中添加另一个属性
类似:
{
name: 'Felipe'
uid: 112233,
data: {
structure: {
school: {
name: 'beta'
}
}
}
}
以前 add_year 不是结构的一部分,所以这部分是新的
school: {
name: 'beta'
add_year: '2020'
}
我怎样才能做到这一点?
我尝试了以下解决方案,但没有成功
(async ()=>{
try {
let teste = await dynamoDb.updateItem({
TableName: 'test',
Key: {
uid: "112233"
},
UpdateExpression: "SET data.#structure.#school = list_append(#structure, :attrValue)",
ExpressionAttributeNames: {
"#data": "data",
"#structure": "structure",
"#school": "school",
},
ExpressionAttributeValues: {
":school":{
"add_year": 2020
}
},
ReturnValues:"UPDATED_NEW "
})
console.log('update',teste)
} catch (error) {
console.log(error)
}
【问题讨论】:
标签: javascript node.js amazon-dynamodb dynamodb-queries dynamo-local