对象数组内的 DynamoDB 更新(nodejs) [英] DynamoDB update inside an array of objects (nodejs)

查看:15
本文介绍了对象数组内的 DynamoDB 更新(nodejs)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到 DynamoDB 可以在数组中添加和删除项目,但是如果您想专门更新某个对象内的特定项目,如何搜索该项目?例如:在 MongoDB 中,您可以搜索 someitem.$.subitem 并更新该特定项目.有没有办法使用 DynamoDB 做到这一点?

I noticed that DynamoDB can add and remove items from an array but how do you search for an specific item inside an object if you want to update that one specifically? For example: In MongoDB you can search for someitem.$.subitem and update that specific item. Is there a way on how to do this with DynamoDB?

Item: {
  someitem: [
    {
      subitem: "id",
      somevalue: "something"
    }
  ]
}

我会说这是基本功能,但似乎不容易找到(甚至不受支持)

I would say this is basic functionality but seems not easy to find (or even unsupported)

推荐答案

TableName : 'tablename', 
Key : { id: id}, 
ReturnValues : 'ALL_NEW',
UpdateExpression : 'set someitem['+`index`+'].somevalue = :reply_content', 
ExpressionAttributeValues : { ':reply_content' : updateddata }

通过数组索引编辑数组元素

array element edit via array index

这篇关于对象数组内的 DynamoDB 更新(nodejs)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆