Building a Request

To perform operations on DynamoDB you will need to create a request that includes both an Action and Payload.

An Action is the operation you would like to perform. See Actions.

A Payload is a data structure that includes the needed parameters for an Action. You can derive payload parameters by browsing the DynamoDB API Documentation.

Payloads in this documentation are shown using Lua table structures, which have been converted from JSON.

Important

When viewing the DynamoDB API Documentation, all payloads for DynamoDB are shown using JSON notation. You will need to convert the JSON stylings to Lua table structures. If you'd rather construct payloads using JSON, then be sure to json.encode() your payload before making a request.

For examples of the different types of payloads see Examples.


Actions

Actions are the operations to be perfomed against the DynamoDB service. You must provide an action to the request method.

Example

db:request("GetItem", payload)

Items

  • GetItem
  • PutItem
  • UpdateItem
  • DeleteItem

Scan/Query

  • Scan
  • Query

Tables

  • CreateTable
  • ListTables
  • DescribeTable
  • DeleteTable

Batch

  • BatchGetItem
  • BatchWriteItem

Tip

For a complete list of actions available see DynamoDB Actions.


Payloads

A payload contains the required parameters for any given action. Payload details can be found in the DynamoDB API Documentation.

For some example payload structures see Examples.

Attribute Types

DynamoDB supports a variety of attribute types that you must specify for all attribute values in the payload. They are notated using a string code.

Code Type
S String
N Number
B Binary
M Map
L List
SS String Set
NS Number Set
BS Binary Set
BOOL Boolean
NULL Null

For more details see DynamoDB AttributeValue.

To indicate an attribute type, you create a table with the type code as the key, and the data as the value.

Examples

--String
local str = {S="My Best Song"}

--Number 
local num = {N=12}

--Map
local map = {M = 
{
  Artist = {S="The Acme Band"},
  SongTitle = {S="Super Fan"},
  Rating = {N=10}
}}

--List
local list = {L =
{
  {S="Blue"}, {BOOL=false}, {N=23}
}}

--Number Set
local num_set = {NS = {
  {N=12}, {N=45}, {N=2.45}
}}

Tip

You can also use API methods to create attribute values. See Attribute Type Methods.