fireproofsocks

fireproofsocks

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:

{:error,
 {"ValidationException",
  "Either the KeyConditions or KeyConditionExpression parameter must be specified in the request."}}

I am able to run a query like the following:

Dynamo.query("my_table", 
   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!

First Post!

brunoripa

brunoripa

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.

Where Next?

Popular in Questions Top

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

We're in Beta

About us Mission Statement