简体   繁体   中英

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".

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.
  2. Perform 2 updates, one with the conditional expression for "High" and one for the "Low" conditional expression.

The basis of the question is this: "Can I use the conditionExpression to perform multiple, non-dependant update conditions on seperate attributes?"

I'm afraid its not possible to have 2 non-dependent conditions on the same UpdateItem API call.

Your first options is more cost effective, however, you may need to use versioning if you have high concurrency.

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