node package manager
Don’t reinvent the wheel. Reuse code within your team. Create a free org »

node-dynamo

node-dynamo Build Status

Easily create and recreate dynamodb tables and sample data. This package provides the cli and sdk.

Installing

npm install node-dynamo --save
cp node_modules/node-dynamo/default.config.js

Setup

Modify default configuration file default.config.js.

node-dynamo requires sufficient AWS DynamoDB permission to modify the DynamoDB tables. It relies on aws-sdk library to get the credential.

See configuring aws sdk in node.js

I personally put my credential in ~/.aws/credentials.

When using seed-cordova, webpack reads the credential from ~/.aws/config.json

CLI Usage

dynamo createtable
dynamo createfake
dynamo create --testId 8888 --company 'pt bangun persada'
dynamo read --testId 8888
dynamo update --testId 8888 --company 'new company LLC'
dynamo delete --testId 8888
dynamo deletetable

API Usage

const defaultDb = require('node-dynamo')('./default.config.js');
 
defaultDb.createTable(function(err, data) {
    console.log('table', data.TableDescription.TableName, 'created');
});
 
defaultDb.deleteTable(function(err, data){
    ...
});
 
defaultDb.createFake(function(err, data) {
    ...
});
 
defaultDb.create(record, function(err, data) {
    ...
});
 
function callback(err, data) {
    if (err) {
        console.log('Error:', err);
    } else {
        console.log('Result:', data);
    }
}
 
defaultDb.read(record, callback);
 
defaultDb.update(record, callback);
 
defaultDb.delete(record, callback);
 
defaultDb.list(record, callback);

License

(C) 2015 Louis Larry
MIT License