DynamoDB Conditional Checks on Arrays of Strings
-
12-12-2019 - |
Question
Can I check if part of an element exists in an Array of Strings, or check if multiple elements exist in one query? So:
1) Does an element start with 'aaa:'
in the array ['aaa:1', 'bab:0', 'aab:1']
2) Does the element 'aaa:1' OR 'aaa:0'
exist in the array ['aaa:1', 'bab:0','aab:1']
If so, do not execute the API operation.
Is this possible? The Documentation isn't clear if UPDATE_ITEM is this robust or not.
Solution
The short answer is: NO for both
The long answer is:
- Point 1) will never be possible
- Point 2) can be done using the CONTAINS filter of the scan operation but... only for a single match. No "OR" stuff. However, scan is both slow and expensive and thus heavily discouraged.
UPDATE_ITEM conditions will only allow exact matches.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow