# simple-dynamodb-query

> Better DynamoDB Query

Latest version **0.2.1** (published 2021-12-23) · ISC license · 0 weekly downloads

## Install

```sh
npm install simple-dynamodb-query
pnpm add simple-dynamodb-query
yarn add simple-dynamodb-query
bun add simple-dynamodb-query
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2021-12-23 |
| First published | 2021-12-22 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 30.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Sander Machado |
| Maintainers | sander.machado |
| Keywords | dynamodb, query, query-builder |

## Links

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

## Dependencies (2)

- [@aws-sdk/lib-dynamodb](https://npm.io/package/@aws-sdk/lib-dynamodb.md) ^3.44.0
- [@aws-sdk/client-dynamodb](https://npm.io/package/@aws-sdk/client-dynamodb.md) ^3.44.0

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 0.2.1 (latest) — 2021-12-23
- 0.2.0 — 2021-12-23
- 0.1.1 — 2021-12-22
- 0.1.0 — 2021-12-22

## README

# Simple DynamoDB query

**Description**:  Writing querry operation in the new V3 node api is still a pain. This gets slightly easier using the documentclient but it's still far from an enjoyable experience. That's why this package was created. It makes writing querries that are fully compatible with the API and mocking library very easy.

  - **Technology stack**: This project is written in TypeScript and meant as a small import into your current workflow.
  - **Status**:  Early Alpha [CHANGELOG](CHANGELOG.md).
  - There are a few other query builders for DynamoDB atm but none of them let you integrate with API provided from AWS. This is a simple drop in replacement class.


## Dependencies

The only not dev dependency is the "@aws-sdk/lib-dynamodb" package.

## Installation

just run npm install simple-dynamodb-query

## Usage

If you want to query a PK you can do this very easily like this.
```javascript
           const client = new DynamoDBClient({region: 'eu-west-1'});
           const docClient = DynamoDBDocumentClient.from(client);
           
           const command = new SimpleQueryCommand({
               TableName: 'PatientTasks',
               partitionKey: {
                   _PK: 'task_org.entity_shift'
               }
           });
           const result = await docClient.send(command);
```
If you want to filter on one of <, <=, >, >=, BETWEEN, BEGINS_WITH
```javascript
           const client = new DynamoDBClient({region: 'eu-west-1'});
           const docClient = DynamoDBDocumentClient.from(client);
           
           const command = new SimpleQueryCommand({
               TableName: 'PatientTasks',
               partitionKey: {
                   _PK: 'task_org.entity_shift'
               }
           }).sortKey('_SK')
            .between('0', '400');
           const result = await docClient.send(command);
```
If you want to query a GSI just like the regular API you just add IndexName
```javascript
           const client = new DynamoDBClient({region: 'eu-west-1'});
           const docClient = DynamoDBDocumentClient.from(client);
           
           const command = new SimpleQueryCommand({
               TableName: 'PatientTasks',
               IndexName: 'GlobalIndex1'
               partitionKey: {
                   _PK: 'task_org.entity_shift'
               }
           }).sortKey('_SK')
            .between('0', '400');
           const result = await docClient.send(command);
```
Ofcourse this is also compatible with async generators
```javascript
        const paginatorConfig = {
            client: docClient,
            pageSize: 25
        };
        
        const command = new SimpleQueryCommand({
               TableName: 'PatientTasks',
               IndexName: 'GlobalIndex1'
               partitionKey: {
                   _PK: 'task_org.entity_shift'
               }
           });
           
        const page = paginateQuery(paginatorConfig, command.input);

        for await (const item of page) {
            console.log(page);
        }
```


## Getting help

If you have questions, concerns, bug reports, etc, please file an issue in this repository's Issue Tracker.

## Getting involved

Currently still looking at other classes that could use a more dev friendly api.


----

## Open source licensing info
1. [TERMS](TERMS.md)
2. [LICENSE](LICENSE)
3. [CFPB Source Code Policy](https://github.com/cfpb/source-code-policy/)


----

## Credits and references

1. Dynongo https://github.com/SamVerschueren/dynongo
2. AWS API https://github.com/aws/aws-sdk-js-v3

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