dynamo-as-promised

A promise-based client for Amazon's DynamoDB.

A Promise-Based DynamoDB Client

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 = require("dynode-as-promised").Client;
var client = new Client({accessKeyId: "AWSAccessKey", secretAccessKey: "SecretAccessKey"});

Then you have the following methods available:

Corresponds to DynamoDB's GetItem command. Fulfills with a hash representing the returned item.

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.

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).


Wondering about the Async suffix? It's a convention I'm borrowing from the Windows Runtime API, as a way of differentiating promise-returning functions from synchronous functions or functions that use Node-style callbacks. To be honest, I'm not sure if I like it, so that might go away in the future.