dynamo-as-promised v0.4.3
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!
Usage
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:
client.getAsync(table, key)
Corresponds to DynamoDB's GetItem command. Fulfills with a hash representing the returned item.
client.scanAsync(table, query)
Corresponds to DynamoDB's Scan command. Fulfills with an array of hashes representing the returned items.
client.putAsync(table, values)
Corresponds to DynamoDB's PutItem command.
client.updateAsync(table, key, values)
Corresponds to DynamoDB's UpdateItem command.
client.deleteAsync(table, key)
Corresponds to DynamoDB's DeleteItem command.
client.deleteMultipleAsync(table, keys)
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.