Querying AWS DynamoDB using Ruby

user1813603

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

console 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)

Chen Harel

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]

編集
0

コメントを追加

0

関連記事

分類Dev

How to query AWS DynamoDb using KeyConditionExpression?

分類Dev

AWS ruby sdkv2-dynamodbクエリ

分類Dev

Querying a parameter that’s not an index on DynamoDb

分類Dev

AWS DynamoDB Scan and FilterExpression using array of hash values

分類Dev

DynamoDB : SET list_append not working using aws sdk

分類Dev

querying using count

分類Dev

AWS DynamoDB TTL

分類Dev

AWS dynamoDB query by date

分類Dev

AWS Dynamodb ContinuousBackupsUnavailableException

分類Dev

AWS dynamodb endpoints is not correct

分類Dev

AWS DynamoDB DAX "NoRouteException"

分類Dev

Querying mongoDB on Date using R

分類Dev

aws DynamoDB gives "write EPROTO"

分類Dev

updating a JSON array in AWS dynamoDB

分類Dev

Getting AngularJS to work with AWS DynamoDB

分類Dev

Connect Android App to AWS dynamoDB

分類Dev

AWS DynamoDBクエリ

分類Dev

AWS SDK .NET DynamoDB ASYNC

分類Dev

Querying Couchbase using N1QL

分類Dev

Querying on multiple Hive stores using Apache Spark

分類Dev

Querying json object in dataframe using Pyspark

分類Dev

Querying a referenced document in MongoDB using Mongoose

分類Dev

Django querying using array for column value

分類Dev

Querying the min element using LINQ inside Tasks

分類Dev

Index error on querying google datastore using gcloud

分類Dev

Using SSE with Laravel without querying the database

分類Dev

AWS DynamoDB on Lambda not returning inserted data

分類Dev

Creating a unique Primary Key for use in AWS DynamoDB

分類Dev

価格:AWS DynamodbとAWSCloudwatch