A promise-based client for Amazon's DynamoDB.
Dynamo as Promised is a client for Amazon's DynamoDB that returns promises to represent its asynchronous operations. It is primarily a thin adapter around dynode to transform its Node-style callback-accepting methods into ones returning Q promises.
This is very much an alpha release: it only supports the small subset of the DynamoDB API that I have found necessary for other projects. Pull requests and fixes welcome!
First, get a client:
var Client = Client;var client = accessKeyId: "AWSAccessKey" secretAccessKey: "SecretAccessKey" ;
Optionally, get a table:
var table = client;
Then you have the following methods available, either on the table as documented below, or directly on the client by passing the table name in as an additional first parameter:
Corresponds to DynamoDB's GetItem command. Fulfills with a hash representing the returned item.
Corresponds to DynamoDB's Query command. Fulfills with an array of hashes representing the returned items.
Corresponds to DynamoDB's Scan command. Fulfills with an array of hashes representing the returned items.
Corresponds to DynamoDB's PutItem command.
Corresponds to DynamoDB's UpdateItem command.
onlyIfExists can be supplied in order to do conditional updates. It takes a key name (or object mapping
key types to key names), which is used to build the appropriate
"Expected" parameters to send to DynamoDB. Example:
Corresponds to DynamoDB's UpdateItem command with the
ReturnValues parameter set to
ALL_NEW, so that
it can fulfill with a hash representing the updated item. As with
update, you can supply
do conditional updates.
Corresponds to DynamoDB's DeleteItem command.
Acts as a wrapper around DynamoDB's BatchWriteItem command, taking an array of keys (of any size) and using them to perform an appropriate number of delete operations, in batches of 25 at a time (DynamoDB's maximum).