# dynamodb-helper

Latest version **1.0.11** (published 2017-10-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install dynamodb-helper
pnpm add dynamodb-helper
yarn add dynamodb-helper
bun add dynamodb-helper
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.11 |
| Published | 2017-10-11 |
| First published | 2017-09-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | andy lai |
| Maintainers | andy51002000 |

## Links

- npm: https://www.npmjs.com/package/dynamodb-helper
- npm.io page: https://npm.io/package/dynamodb-helper

## Recent versions

- 1.0.11 (latest) — 2017-10-11
- 1.0.10 — 2017-10-11
- 1.0.9 — 2017-10-11
- 1.0.8 — 2017-10-11
- 1.0.7 — 2017-09-15
- 1.0.6 — 2017-09-15
- 1.0.5 — 2017-09-15
- 1.0.3 — 2017-09-15
- 1.0.2 — 2017-09-15
- 1.0.1 — 2017-09-15
- 1.0.0 — 2017-09-15

## README

# dynamodb-helper




## Installation

```sh
npm install dynamodb-helper
```

## API

```js
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 
```js
{ 
    "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.


```js

/*  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);

});
```

---
_Source: https://npm.io/package/dynamodb-helper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
