npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dammo

v0.3.7

Published

Simple DynamoDB Library for Node.js

Downloads

5

Readme

Basics

A Simple, efficient and complete DynamoDB driver for Node.js, with:

  • Syntactic sweeteners/mapping to handle Amazon DynamoDB's JSON format in NodeJS
  • Efficient and transparent authentication and authentication refresh using Amazon STS
  • Integrated retry logic similar to Amazon's own PhP, Java libraries
  • Currently in production in multiple independent organizations with more than 80 write/s, 60 read/s
  • Support for all exposed DynamoDB operations

Discussion Group: http://groups.google.com/group/node-dynamodb

Usage

var ddb = require('dynamodb').ddb({ accessKeyId: '',
                                    secretAccessKey: '' });

Available options for the constructor are the following:

  • accessKeyId: the AWS AccessKeyId to use
  • secretAccessKey: the AWS SecretAccessKey associated
  • endpoint: the Region endpoint to use (defaults to: dynamodb.us-east-1.amazonaws.com)
  • agent: The NodeJS http.Agent to use (defaults to: undefined)
  • sessionToken: forced temporary session credential (defaults to: undefined)
  • sessionExpires: forced temeporary session credential (defaults to: undefined)

CreateTable

ddb.createTable('foo', { hash: ['id', ddb.schemaTypes().string],
                         range: ['time', ddb.schemaTypes().number] },
                {read: 10, write: 10}, function(err, details) {});

// res: { "CreationDateTime": 1.310506263362E9,
//        "KeySchema": { "HashKeyElement": { "AttributeName": "AttributeName1",
//                                           "AttributeType": "S"},
//                       "RangeKeyElement": { "AttributeName": "AttributeName2",
//                                            "AttributeType": "N"} },
//        "ProvisionedThroughput":{ "ReadCapacityUnits": 5,
//                                  "WriteCapacityUnits": 10 },
//        "TableName":"Table1",
//        "TableStatus":"CREATING" }

ListTables

ddb.listTables({}, function(err, res) {});

// res: { LastEvaluatedTableName: 'bar',
          TableNames: ['test','foo','bar'] }

DescribeTable

ddb.describeTable('a-table', function(err, res) {});

// res: { ... }

PutItem

// flat [string, number, string array or number array] based json object
var item = { score: 304,
             date: (new Date).getTime(),
             sha: '3d2d6963',
             usr: 'spolu',
             lng: ['node', 'c++'] };

ddb.putItem('a-table', item, {}, function(err, res, cap) {});

GetItem

ddb.getItem('a-table', '3d2d6963', null, {}, function(err, res, cap) {});

// res: { score: 304,
//        date: 123012398234,
//        sha: '3d2d6963',
//        usr: 'spolu',
//        lng: ['node', 'c++'] };

DeleteItem

ddb.deleteItem('a-table', 'sha', null, {}, function(err, res, cap) {});

UpdateItem

ddb.updateItem('a-table', '3d2d6963', null, { 'usr': { value: 'smthg' } }, {},
               function(err, res, cap) {});

ddb.consumedCapacity();

BatchGetItem

ddb.batchGetItem({'table': { keys: ['foo', 'bar'] }}, function(err, res) {
    if(err) {
      console.log(err);
    } else {
      console.log(res);
    }
 });

// res: { ConsumedCapacityUnits: 1.5,
          items: [...] };

BatchWriteItem

//ddb.batchWriteItem(PutRequest, DeleteRequest, cb)
ddb.batchWriteItem({'table': [item1, item2]}, {'table': ['foo', 'bar']}, function(err, res) {
    if(err) {
      console.log(err);
    } else {
      console.log(res);
    }
 });

// res: { UnprocessedItems: { ... } };

Query

ddb.query('test', '3d2d6963', {}, function(err, res, cap) {...});

// res: { count: 23,
//        lastEvaluatedKey: { hash: '3d2d6963' },
//        items: [...] };

Scan

ddb.scan('test', {}, function(err, res) {
    if(err) {
      console.log(err);
    } else {
      console.log(res);
    }
 });

// res: { count: 23,
//        lastEvaluatedKey: { hash: '3d2d6963' },
//        items: [...] };

More complete usage can be found in the examples directory

Run the Tests

Put in your environment:

export DYNAMODB_ACCESSKEYID=YOURACCESSKEYID
export DYNAMODB_SECRETACCESSKEY=YOURSECRETKEYID
export DYNAMODB_TEST_TABLE1=test

Make sure you have a test table created and available with sha as a hash key (string). Make sure to select Hash as the Primary Key Type. Then run:

make test

If you are getting one of these errors:

  • User: ... is not authorized to perform: dynamodb:PutItem on resource you need to add AmazonDynamoDBFullAccess to the user in IAM policy editor.

License

Distributed under the MIT License.

Contributors

@karlseguin (Karl Seguin)
@imekinox (Juan Carlos del Valle)
@phstc (Pablo Cantero)
@cstivers78 (Chris Stivers)
@garo (Juho Mäkinen)
@tax (Paul Tax)
@alexbosworth (Alex Bosworth)
@jimbly (Jimb Esser)
@n1t0 (Anthony Moi)
@krasin
@aws-ew-dev