I have inherited a DynamoDB table with three columns of which one is a key
Id - String - hashKey
ProductID - String
UsageCount - number
I want to run a query/scan that logically equates to the following
select ProductID, UsageCount where ProductID='abcd'
Although ProductID is not a key of any sort, I can use the AmazonDynamoDB console and add a filter
and get just what I want. So I assume I should be able to do the same thing with code (although everyone talks about using hash and range keys for such purposes)
I am trying to do the same thing with RUBY but not getting results...
resp = $dynamodb.scan(
:table_name => PRODUCTTABLE,
:projection_expression => "Id, TenantId, SeatCount",
:filter_expression => 'TenantId = abcd'
)
Could someone help me with the correct syntax for doing this? I tried numerous variations that all throw exceptions except for the above syntax that does not throw an exception but returns zero rows. So Im thinking it must be close :) (or maybe not)
You have to use both filter_expression but make it 'TenantId = :val'
and then pass :val
with expression_attribute_names
and expression_attribute_values
Even though it's in Java, this doc will help clear things out for you
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加