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

Fl4m3Ph03n1x
Background Let’s assume I have a typical GenServer that receives messages as requests, does some operation in a DB and returns responses....
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
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 record...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
mathew4509
I have a list say x = ["23gh", "56kh", "97mh"] I would like to pass each element to Val in each iteration. Say, in iteration 1 -------...
New
sabri
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size? Thanks
New

Other popular topics Top

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
peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
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
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

We're in Beta

About us Mission Statement