# dynamodb-storage-backend

> DynamoDB storage backend

Latest version **1.1.0** (published 2018-12-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install dynamodb-storage-backend
pnpm add dynamodb-storage-backend
yarn add dynamodb-storage-backend
bun add dynamodb-storage-backend
```

## 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.1.0 |
| Published | 2018-12-31 |
| First published | 2016-12-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 62.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Tobias Rask |
| Maintainers | tobiasrask |
| Keywords | DynamoDB, Entities |

## Links

- npm: https://www.npmjs.com/package/dynamodb-storage-backend
- Repository: https://github.com/tobiasrask/dynamodb-storage-backend
- Homepage: https://github.com/tobiasrask/dynamodb-storage-backend#readme
- Issues: https://github.com/tobiasrask/dynamodb-storage-backend/issues
- npm.io page: https://npm.io/package/dynamodb-storage-backend

## Dependencies (1)

- [entity-api](https://npm.io/package/entity-api.md) 0.1.1

## Recent versions

- 1.1.0 (latest) — 2018-12-31
- 1.0.21 — 2017-04-21
- 1.0.20 — 2017-01-12
- 1.0.19 — 2017-01-01
- 1.0.18 — 2016-12-30
- 1.0.17 — 2016-12-30
- 1.0.16 — 2016-12-30
- 1.0.15 — 2016-12-30
- 1.0.14 — 2016-12-30
- 1.0.13 — 2016-12-30
- 1.0.12 — 2016-12-29
- 1.0.11 — 2016-12-29
- 1.0.10 — 2016-12-29
- 1.0.9 — 2016-12-29
- 1.0.8 — 2016-12-23
- … 7 more at https://npm.io/package/dynamodb-storage-backend/versions

## README

# DynamoDB storage backend for entity-api
[dynamodb-storage-backend](https://www.npmjs.com/package/dynamodb-storage-backend) provides DynamoDB storage for [Entity API](https://www.npmjs.org/package/entity-api).

### Installation

Using [npm](https://www.npmjs.com/):

    $ npm install --save dynamodb-storage-backend

### Example usage

```js

import AWS from 'aws-sdk'
import {
  DynamoDBStorageBackend,
  DynamoDBStorageHandler
  } from 'dynamodb-storage-backend'

AWS.config.update({
  region: 'eu-west1'
})

const DB_SCHEMAS = [
  {
    schema:  {
      TableName: 'message',
      AttributeDefinitions: [
        {
          AttributeName: 'id',
          AttributeType: 'S'
        }
      ],
      KeySchema: [
        {
          AttributeName: 'id',
          KeyType: 'HASH'
        }
      ],
      ProvisionedThroughput:  {
        ReadCapacityUnits: '1',
        WriteCapacityUnits: '1'
      }
    }
  }
]

const backend = new DynamoDBStorageBackend({
    dynamodb: new AWS.DynamoDB({
      // Dynamodb endpoint to be used. This uses Dynamodb local
      endpoint: new AWS.Endpoint('http://localhost:8000')
    })
})

class MessageEntityType extends EntityType {

  constructor(variables = {}) {
    variables.entityTypeId = 'message'
    variables.entityClass = MessageEntity
    variables.handlers = {
      storage: new DynamoDBStorageHandler({
        tablePrefix: 'entity_',
        storage: backend,
        schemaData: DB_SCHEMAS
      }),
      view: new EntityViewHandler(variables),
    }
    super(variables)
  }
}

```

### Test
Run tests using [npm](https://www.npmjs.com/):

    $ npm run test

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