# @banxware/simple-repository

> A simple repository implementation for DynamoDB and S3

Latest version **2.10.0** (published 2025-07-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @banxware/simple-repository
pnpm add @banxware/simple-repository
yarn add @banxware/simple-repository
bun add @banxware/simple-repository
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

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

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.10.0 |
| Published | 2025-07-28 |
| First published | 2022-12-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 78.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Banxware GmbH |
| Maintainers | dvarela, sergei-konovalov-banxware, guilherme.oliveira, fheiss_bxw, banxwareinvoice |

## Links

- npm: https://www.npmjs.com/package/@banxware/simple-repository
- npm.io page: https://npm.io/package/@banxware/simple-repository

## Recent versions

- 2.10.0 (latest) — 2025-07-28
- 2.9.0 — 2025-07-11
- 2.8.0 — 2025-07-07
- 2.7.0 — 2025-05-02
- 2.6.0 — 2025-04-24
- 2.5.0 — 2023-12-07
- 2.4.0 — 2023-12-04
- 2.3.0 — 2023-11-16
- 2.2.0 — 2023-11-16
- 2.1.0 — 2023-04-05
- 1.8.0 — 2023-04-03
- 1.7.0 — 2023-04-03
- 1.6.0 — 2023-03-17
- 1.4.0 — 2022-12-12
- 1.3.0 — 2022-12-12
- … 3 more at https://npm.io/package/@banxware/simple-repository/versions

## README

# Simple Repository

## Install

```
$ npm i @banxware/simple-repository
```

## Usage

### Dynamo Repository

```ts
type User {
  id: string
  firstName: string
  lastName: string
  active: boolean
}

class UserRepository extends SimpleDynamoRepository<User> {
  async findActiveUsersByName(name: string): Promise<User> {
    return await this.findByQuery({
      IndexName: 'name',
      KeyConditionExpression: 'name = :name AND active = :active',
      ExpressionAttributeValues: {
        ':name': name,
        ':active': true,
      },
    })
  }
}

const userRepository = new UserRepository(new DynamoDBClient({ region: 'eu-central-1' }), 'users')

userRepository.save({ id: 'uuid', firstName: 'john', lastName: 'doe', active: true })
userRepository.save({ id: 'uuid2', firstName: 'john', lastName: 'travolta', active: false })
userRepository.findOne('uuid')
userRepository.findActiveUsersByName('john')
userRepository.findAll()
```

### S3 Repository

```ts
type File {
  key: string
  content: Uint8Array | string | Buffer
  contentType: string
  someMetaData: string
}

class FileRepository extends SimpleS3Repository<File> {
}

const s3Repository = new FileRepository<File>(new S3Client({ region: 'eu-central-1' }), 'my-bucket')

s3Repository.save({ key: 'foo/bar.json', content: '{}', contentType: 'application/json', someMetaData: 'super cool file' })
s3Repository.getOneAsString('foo/bar.json')
s3Repository.getOneMetadata('foo/bar.json')
s3Repository.deleteOne('foo/bar.json')
s3Repository.getSignedUploadUrl('foo/another-file.json')
s3Repository.getSignedDownloadUrl('foo/another-file.json')
s3Repository.list('foo')

```

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