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

查看:148
本文介绍了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)

推荐答案

AWS不允许在单个更新请求中对其进行修改,但在以下答案中发现了更多信息:
更新a-json-array-in-aws-dynamodb

AWS does not permit to modify it in a single update request more info was found in the following answers: updating-a-json-array-in-aws-dynamodb.

他们提出的解决方案是将架构从数组更改为 {} ,或者实施自定义函数并遍历每个数组并找到要更新的新ID,这样可以说以编程方式更新您的json,然后插入整个对象。

The solution that they propose is to change the schema from array to {}, or to implement a custom functions and iterate through each array and find your new id to update, so to speak to programatically update your json and then insert whole object.

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

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