简体   繁体   English

DynamoDb 非依赖属性的多条件更新

[英]DynamoDb Multiple Conditional Updates of Non-dependant Attributes

I am using the Javascript SDK for AWS and I am attempting to perform a single update operation on OHLC (Open, High, Low, Close) data and I only want to update the "High" attribute if the new value is higher than the stored value and the opposite for the "Low".我正在为 AWS 使用 Javascript SDK,我正在尝试对 OHLC(开盘价、高价、低价、收盘价)数据执行单个更新操作,如果新值高于存储的值,我只想更新“高”属性价值和相反的“低”。

As far as I can tell, there are 2 options:据我所知,有两种选择:

  1. Query the dB to get the current OHLC, calculate the differences, then update the dB again.查询 dB 以获取当前 OHLC,计算差异,然后再次更新 dB。
  2. Perform 2 updates, one with the conditional expression for "High" and one for the "Low" conditional expression.执行 2 次更新,一次使用“高”条件表达式,一次使用“低”条件表达式。

The basis of the question is this: "Can I use the conditionExpression to perform multiple, non-dependant update conditions on seperate attributes?"问题的基础是:“我可以使用 conditionExpression 对单独的属性执行多个非依赖更新条件吗?”

I'm afraid its not possible to have 2 non-dependent conditions on the same UpdateItem API call.恐怕在同一个UpdateItem API 调用中不可能有 2 个非依赖条件。

Your first options is more cost effective, however, you may need to use versioning if you have high concurrency.您的第一个选项更具成本效益,但是,如果您具有高并发性,则可能需要使用版本控制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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