Class: Mara::Query
Overview
Perform calls to DynamoDB for fetching
Defined Under Namespace
Classes: Result
Class Method Summary collapse
-
.get_item(query_params) ⇒ Mara::Query::Result
Perform a single item get request by the primary key.
Methods included from DynamoHelpers
Class Method Details
.get_item(query_params) ⇒ Mara::Query::Result
Perform a single item get request by the primary key.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/mara/query.rb', line 39 def get_item(query_params) client, table_name = config_params(query_params) primary_key = query_params.fetch(:key) projection_expression = query_params.fetch(:projection_expression, nil).presence params = { key: primary_key, table_name: table_name, return_consumed_capacity: 'TOTAL', projection_expression: projection_expression } result = Mara.instrument('get_item', params) do client.get_item(params) end return nil if result.item.nil? item = format_item(result.item) cc = calculate_consumed_capacity(result.consumed_capacity, table_name) Result.new( [item], cc ) end |