<bdo id='HTjsP'></bdo><ul id='HTjsP'></ul>

  1. <legend id='HTjsP'><style id='HTjsP'><dir id='HTjsP'><q id='HTjsP'></q></dir></style></legend>
    1. <tfoot id='HTjsP'></tfoot>

    2. <small id='HTjsP'></small><noframes id='HTjsP'>

      <i id='HTjsP'><tr id='HTjsP'><dt id='HTjsP'><q id='HTjsP'><span id='HTjsP'><b id='HTjsP'><form id='HTjsP'><ins id='HTjsP'></ins><ul id='HTjsP'></ul><sub id='HTjsP'></sub></form><legend id='HTjsP'></legend><bdo id='HTjsP'><pre id='HTjsP'><center id='HTjsP'></center></pre></bdo></b><th id='HTjsP'></th></span></q></dt></tr></i><div id='HTjsP'><tfoot id='HTjsP'></tfoot><dl id='HTjsP'><fieldset id='HTjsP'></fieldset></dl></div>

      DynamoDB - 如何在一次更新中创建地图并向其添加属

      时间:2023-09-03

        <bdo id='UgiJX'></bdo><ul id='UgiJX'></ul>
          <tbody id='UgiJX'></tbody>
        • <legend id='UgiJX'><style id='UgiJX'><dir id='UgiJX'><q id='UgiJX'></q></dir></style></legend>
          • <small id='UgiJX'></small><noframes id='UgiJX'>

            <i id='UgiJX'><tr id='UgiJX'><dt id='UgiJX'><q id='UgiJX'><span id='UgiJX'><b id='UgiJX'><form id='UgiJX'><ins id='UgiJX'></ins><ul id='UgiJX'></ul><sub id='UgiJX'></sub></form><legend id='UgiJX'></legend><bdo id='UgiJX'><pre id='UgiJX'><center id='UgiJX'></center></pre></bdo></b><th id='UgiJX'></th></span></q></dt></tr></i><div id='UgiJX'><tfoot id='UgiJX'></tfoot><dl id='UgiJX'><fieldset id='UgiJX'></fieldset></dl></div>

                <tfoot id='UgiJX'></tfoot>
                本文介绍了DynamoDB - 如何在一次更新中创建地图并向其添加属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                如果它不存在,我想创建一个新地图,然后向该地图添加一个属性.像这样的:

                I want to create a new map if it doesn't exist and then add an attribute to that map. Something like this:

                SET #A = if_not_exists(#A, :emptyMap), #A.#B = :somevalue

                但是执行上述操作给我的错误是 两个文档路径相互重叠

                However doing the above gives me the error saying Two document paths overlap with each other

                我唯一想做的另一件事是进行两次更新,一次创建任何空地图,然后另一次设置属性.

                The only other thing I am thinking to do is do TWO updates, one to create any empty maps and then another to set attributes.

                有没有办法在一次更新中做到这一点?

                更新

                另一个用例是创建包含其他地图的地图.目前,我能想到的创建以下内容的唯一方法是 3 个单独的更新调用来创建地图(如果需要),然后再调用另一个更新调用来添加属性:

                Another use case is creating maps that contain other maps. Currently the only way I can think of to create the following is 3 separate update calls to create the maps if necessary and then another update call to add attributes:

                {
                  Entities: { A: { B: {} } },
                }
                

                一定有更好的办法.

                推荐答案

                您可以分摊执行两次单独的 UpdateItem 调用的成本,一次创建#A,另一个通过将#B 添加到#A 来将#B 添加到#A#A 有条件更新.

                You can amortize the cost of doing two seperate UpdateItem calls, one to create #A, and the other to add #B to #A by adding #B to #A with a conditional update.

                UpdateExpression: SET #A.#B = :valueOfB
                ConditionExpression: attribute_exists(#A)
                

                如果您向#A 添加许多条目,那么您只创建一次#A,并且随着#A 中条目数量的增加,创建#A 的摊销时间接近于零.如果您捕获到 ConditionalCheckFailedException,那就是您将在其中创建带有 #B 的地图并调用 UpdateItem:

                If you add many entries to #A, then you only create #A once, and as the number of entries in #A increases, the amortized time to create #A approaches zero. If you catch a ConditionalCheckFailedException, that is when you would create the map with #B already in it and call UpdateItem:

                UpdateExpression: SET #A = :valueOfMapWithBInIt
                ConditionExpression: attribute_not_exists(#A)
                

                这篇关于DynamoDB - 如何在一次更新中创建地图并向其添加属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:AWS SDK DynamoDB 客户端和 DocumentClient 之间的区别? 下一篇:使用 Node JS 递归获取 DynamoDB 查询中的所有项目

                相关文章

                最新文章

                  <tfoot id='sFLWU'></tfoot>
                    <bdo id='sFLWU'></bdo><ul id='sFLWU'></ul>
                1. <i id='sFLWU'><tr id='sFLWU'><dt id='sFLWU'><q id='sFLWU'><span id='sFLWU'><b id='sFLWU'><form id='sFLWU'><ins id='sFLWU'></ins><ul id='sFLWU'></ul><sub id='sFLWU'></sub></form><legend id='sFLWU'></legend><bdo id='sFLWU'><pre id='sFLWU'><center id='sFLWU'></center></pre></bdo></b><th id='sFLWU'></th></span></q></dt></tr></i><div id='sFLWU'><tfoot id='sFLWU'></tfoot><dl id='sFLWU'><fieldset id='sFLWU'></fieldset></dl></div>

                  <legend id='sFLWU'><style id='sFLWU'><dir id='sFLWU'><q id='sFLWU'></q></dir></style></legend>
                  1. <small id='sFLWU'></small><noframes id='sFLWU'>