Socket
Book a DemoInstallSign in
Socket

dynamodb-helper

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dynamodb-helper

1.0.11
latest
npmnpm
Version published
Maintainers
1
Created
Source

dynamodb-helper

Installation

npm install dynamodb-helper

API

var dbHelper = require('dynamodb-helper')

dbHelper(docClient,tableName)

Create a new dbHelper object for the given docClient and tableName.

.find(queryHashKey, callback)

Get items by queryHashKey from the particular table and process callback function.

.putItem(item)

put item on the particular table

.list(callback)

Get all items from the particular table and process callback function.

Examples

Simple type negotiation

This simple example shows how to use dynamodb-helper to get items from dynamodb and upload items to dynamodb. First we have to require aws-sdk and then configure it by config.json like

{ 
    "accessKeyId": "AKIAJVsdfDSDSsA", 
    "secretAccessKey": "Dsy3GADSASDDFDFzwIx+HJY2jqvjq", 
    "region": "us-east-1" 
}

After that, we create the object of the DocumentClient of Dynamodb and inject it into dbHelper.


/*  Initialize   */
var AWS = require("aws-sdk");
AWS.config.loadFromPath('./config.json');
var docClient = new AWS.DynamoDB.DocumentClient({ apiVersion: '2012-08-10' });

var dbHelper = require('dynamodb-helper');
var Users = new dbHelper(docClient, 'Users');

/*  Find Data   */
Users.find(req.user.id, function (err,data) {
  console.log(data);
  if(err){
    console.log("Error occured");            
    return new Error(err);
  }
  //Do something

  })

/*  Upload Data   */
Users.putItem(  { 
                 id: req.user.id, 
                 devs:[
                        { 
                            sn: req.body.sn, 
                            name: req.body.name 
                        }
                      ] 
                });  

/*  Find all Data   */
Users.list(function(err,data){
  if (err){
    console.log(err);  
  }
  console.log(data);

});

FAQs

Package last updated on 11 Oct 2017

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.