[英]dynogels update trashing other keypairs
Anyone with dynogels experience might be able to help me on this one. 任何具有dynogels经验的人都可以在这一方面帮助我。
Simplified example of my dynamodb table with a nested structure 具有嵌套结构的dynamodb表的简化示例
{
key: xxxxx,
maintenance: {
date1: xxxxxxxx,
date2: xxxxxxxx
}
}
If I update the table and send the below as the update params 如果我更新表格并发送以下内容作为更新参数
key: 1,
maintenance: {
date2: 1970-01-18T09:45:55.452Z
}
then date1: gets trashed from my item in the table 然后date1:从表中的我的物品中删除
Is there some config option in the update call that Im making that I'm missing somewhere to NOT delete values that I dont want to touch/update? 我在更新呼叫中是否有一些配置选项让我失踪,无法删除不想触摸/更新的值?
Thanks 谢谢
You can use dot notation in your UpdateExpression
in order to set values for nested properties. 您可以在
UpdateExpression
中使用点符号来设置嵌套属性的值。
var params = {};
params.UpdateExpression = 'SET #maintenance.date2 = :date2';
params.ExpressionAttributeNames = {
'#maintenance' : 'maintenance',
};
params.ExpressionAttributeValues = {
':date2' : '1970-01-18T09:45:55.452Z',
};
Model.update({key : 1}, params, function (err, model) {});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.