简体   繁体   中英

dynogels update trashing other keypairs

Anyone with dynogels experience might be able to help me on this one.

Simplified example of my dynamodb table with a nested structure

{
  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

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.

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) {});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM