- 
                Notifications
    
You must be signed in to change notification settings  - Fork 559
 
Home
        Jesse Schoch edited this page May 8, 2015 
        ·
        2 revisions
      
    a few notes
default test mix env is setup to use dynamodb local
get seems to only want the primary key in the map argument
iex(1)> user = %User{email: "bubba@foo.com", name: "Bubba", age: 23, admin: false}
iex(7)> ExAws.Dynamo.get_item!("Users",user)
** (Protocol.UndefinedError) protocol Enumerable not implemented for %User{admin: false, age: 23, email: "bubba@foo.com", name: "Bubba"}
    (elixir) lib/enum.ex:1: Enumerable.impl_for!/1
    (elixir) lib/enum.ex:112: Enumerable.reduce/3
    (elixir) lib/enum.ex:1265: Enum.reduce/3
    (elixir) lib/enum.ex:915: Enum.into/4
             lib/ex_aws/dynamo/impl.ex:166: ExAws.Dynamo.Impl.get_item/4
             lib/ex_aws/dynamo/impl.ex:171: ExAws.Dynamo.Impl.get_item!/4iex(13)> ExAws.Dynamo.get_item!("Users",%{email: user.email})|> ExAws.Dynamo.Decoder.decode
%{"admin" => false, "age" => 23, "email" => "bubba@foo.com", "name" => "Bubba"}stream_* embeds it's items in "Items"
{:ok,
 %{"Count" => 1, "Items" => #Function<25.29647706/2 in Stream.resource/3>,
   "LastEvaluatedKey" => %{"email" => %{"S" => "bubba@foo.com"}},
   "ScannedCount" => 1}}simple fetch items from stream query, would be nice to have stream_scan!
iex(18)> {:ok,map} = Dynamo.stream_scan("Users", limit: 1)
iex(23)> map["Items"]  |> Stream.map(&(ExAws.Dynamo.Decoder.decode&1))|>Enum.to_list      [%{"admin" => false, "age" => 23, "email" => "bubba@foo.com",
   "name" => "Bubba"}]