Example of ExAws.Dynamo.query/2?

I got a bit stuck trying to use ExAws.Dynamo.query/2 … I don’t follow the given example, and Amazon’s docs aren’t very helpful there (presumably, they make sense to you if you’re already drunk on their Kool Aid, but not so much if you’re not in their club).

Am I correct in inferring that a simple SELECT * FROM x is not possible in Dynamo? (Because, like GraphQL, you must specify the columns you want to fetch? What if want the first 3 items from the table?

alias ExAws.Dynamo
Dynamo.query("my_table", limit: 3) 
|> ExAws.request()

results in an error:

  "Either the KeyConditions or KeyConditionExpression parameter must be specified in the request."}}

I am able to run a query like the following:

   limit: 3, 
   expression_attribute_values: [id: "123"], 
   key_condition_expression: "id = :id") 
|> ExAws.request()

But that’s no different than using the Dynamo.get_item/2 function…

What query is Amazon running when you log into the AWS dashboard and inspect the items in your table?

Thanks for any help!

In DynamoDB you have both query and scan operations. scan goes over the whole table, with obvious consequences (billing, op duration, direct relation with number of elements in the table), while query requires a partition key to work. In other words, the query is able to work on a “subset” of the elements in the table.

Basically, if you need elements that are not identified by specific keys (read: you need everything), you have to use scan; but be supercareful about the impact this can have.