# dynamodb-repository

> DynamoDb repository super class for handling data model in dynamoDb

Latest version **1.0.2** (published 2020-05-07) · Apache-2.0 license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-05-07 |
| First published | 2020-05-06 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 12.13 <13 |
| Dependencies | 9 |
| Unpacked size | 96 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| Author | Jakub Synowiec |
| Maintainers | andrade0 |
| Keywords | typescript, dynamodb, repository, aws |

## Links

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

## Dependencies (9)

- [tslib](https://npm.io/package/tslib.md) ~1.10.0
- [dotenv](https://npm.io/package/dotenv.md) ^8.2.0
- [aws-sdk](https://npm.io/package/aws-sdk.md) ^2.659.0
- [inversify](https://npm.io/package/inversify.md) ^5.0.1
- [@types/async](https://npm.io/package/@types/async.md) ^3.2.0
- [@types/aws-sdk](https://npm.io/package/@types/aws-sdk.md) ^2.7.0
- [@types/inversify](https://npm.io/package/@types/inversify.md) ^2.0.33
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.1.13
- [class-transformer](https://npm.io/package/class-transformer.md) ^0.2.3

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2020-05-07
- 1.0.1 — 2020-05-06
- 1.0.0 — 2020-05-06

## README

#Install: 
```
npm install dynamodb-repository
```

###Usage exemple: 
```
import {DiggingDynamodbClient, DiggingDynamodbClientInterface} from "dynamodb-repository";

// define primary key of your table. It can be one or to fields depends on your dynamoDb table setup
class TableKey{
  id: string;
}

// Define the Class your repository is going to use.
class User{
  id: string;
  nameName: string;
  email: string;
}

//Create your repository class and extend from DiggingDynamodbClient, the generic types setted like this: 
class UserRepository extends DiggingDynamodbClient<User, TableKey> {
  constructor(
    public TableName = 'users',
    public classType = User,
  ) {
    super(TableName);
  }
}

//get an instance of your repository
const repository = new UserRepository();

// just use it like this: 
(async () => {
  const u = new User();
  u.id = 'FEZF43TFDF';
  u.nameName = 'andFDrade';
  u.email = 'andradeolivier@gmail.com';
  const key = new TableKey();
  key.id = u.id;
  await repository.insertOne(u);
  const u2 = new User();
  u2.id = u.id;
  u2.nameName = u.nameName;
  u2.email = 'pauline@gmail.com';
  await repository.updateOne(key, u2);
  const user: User = await repository.findOne(key);
  console.log(user)
  await repository.deleteOne(key, 'nameName = :name', {':name': 'andFDrade'});
  const users = await repository.getAll();
  console.log(users)
  await repository.addMany([
    {id: 'RE4', nameName: 'ggfg', email: 'fdfdfd'},
    {id: 'FRE4', nameName: 'fffff', email: 'fdffffdfd'},
    {id: 'RcE4', nameName: 'ggfg', email: 'fdfdfd'},
    {id: 'RjEG4', nameName: 'gfffffffgfg', email: 'fdfdfd'},
    {id: 'RfE4', nameName: 'ggfg', email: 'fdfdffffd'},
    {id: 'RtE4', nameName: 'fffffff', email: 'fdfdfd'},
    {id: 'RttE4', nameName: 'ggfg', email: 'fdfdfd'},
  ]);
  const users1 = await repository.getAll();
  console.log(users1)
})();


```

##.env variables:
```
LOCAL=true // will connect to http://localhost:8000
DEBUG=false
```

##AWS Credentials

They are taken from yout local setup, usualy ~/.aws folder

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