Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dyno

Package Overview
Dependencies
Maintainers
30
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dyno

Simple DynamoDB client

  • 0.7.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
24
decreased by-67.57%
Maintainers
30
Weekly downloads
 
Created
Source

Dyno

The aws-sdk dynamo client is very close to the API, dyno tries to help reduce the amount of repetitive code needed to interact with dynamodb.

First it guesses types. Dynamo is very specific about its types:

{key:{S: 'value'}}

in dyno can be written like:

{key:'value'}

When dyno doesn't do anything to improve a command, it simply passes it through to aws-sdk dynamodb client.

This is the case right now with commands like scan

Installing
 npm install dyno -S

Usage

Setup
var dyno = module.exports.dyno = require('dyno')({
    accessKeyId: 'XXX',
    secretAccessKey: 'XXX',
    region: 'us-east-1',
    table: 'test'
});

putItem
var item = {id: 'yo', range: 5};
dyno.putItem(item, function(err, resp){});

// multiple items
var items = [
        {id: 'yo', range: 5},
        {id: 'guten tag', range: 5},
        {id: 'nihao', range: 5}
    ];
dyno.putItems(items, function(err, resp){})

Set the table name per command:

var item = {id: 'yo', range: 5};
dyno.putItem(item, {table:'myothertablename'}, function(err, resp){});

updateItem
var key = {id: 'yo', range:5};
var item = {put:{a: 'oh hai'}, add:{count: 1}};

dyno.updateItem(key, item, function(err, resp){});

deleteItems
var keys = [
        {id: 'yo', range: 5},
        {id: 'guten tag', range: 5},
        {id: 'nihao', range: 5}
    ];
dyno.deleteItems(keys, function(err, resp){})
query
var query = {id: {'EQ':'yo'}, {range:{'BETWEEN':[4,6]}};

dyno.query(query, function(err, resp){
    assert.deepEqual(resp, {count : 1, items : [{id : 'yo', range : 5 }]});
});

dyno.query(query, {attributes:['range']}, function(err, resp){
    assert.deepEqual(resp, {count : 1, items : [{range : 5 }]});
});

The last key evaluated by dynamodb can be found in the query callback's third argument.

dyno.query(query, {pages: 1}, function(err, resp, metas) {
    next = metas.pop().last;
    ...
});

This key can be passed back in to another query to get the next page of results.

dyno.query(query, {start: next, pages: 1}, function(err, resp, metas) {
    ...
});

Keywords

FAQs

Package last updated on 22 Oct 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc