# dynapromise-full-query

> A full DynamoDB query in a promise.

Latest version **0.0.2** (published 2019-07-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install dynapromise-full-query
pnpm add dynapromise-full-query
yarn add dynapromise-full-query
bun add dynapromise-full-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.0.2 |
| Published | 2019-07-04 |
| First published | 2019-07-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 8.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | ffi67 |

## Links

- npm: https://www.npmjs.com/package/dynapromise-full-query
- npm.io page: https://npm.io/package/dynapromise-full-query

## Dependencies (1)

- [dynopromise-client](https://npm.io/package/dynopromise-client.md) ^0.2.0

## Recent versions

- 0.0.2 (latest) — 2019-07-04
- 0.0.1 — 2019-07-03

## README

# dynapromise-full-query

A full query of a DynamoDB table in a promise; it fetches all items matching the query, not just the first batch returned by AWS.

## Install

```
npm install dynapromise-full-query
```
or
```
yarn add dynapromise-full-query
```

## Usage
### Async/await syntax
```
import fullQuery from 'dynapromise-full-query'
const countAllItems = async () => {
  try {
    const items = await fullQuery(
      { ... }, // Options used in 'new AWS.DynamoDB(options = {})' (see notes),
      { ... }, // Options used in 'dynamodb.query(options = {})' (see notes),
      {
        // Whether or not to surpress returning the results
        noReturn: false,

        // Function to process chunks of items as they are returned from AWS
        onChunk: () => {},

        // Number of times to reattempt retryable errors. Default 50.
        errorRetries: 50,
      }
    )
    console.log(`Query returned ${items.length} item/s`)
  }
  catch (err) {
    console.error(err)
  }
}
```

### Promise syntax
```
const fullQuery = require('dynapromise-full-query');
const countAllItems = fullQuery(
  { ... }, // Options used in 'new AWS.DynamoDB(options = {})' (see notes),
  { ... }, // Options used in 'dynamodb.query(options = {})' (see notes),
  {
    // Whether or not to surpress returning the results
    noReturn: false,

    // Function to process chunks of items as they are returned from AWS
    onChunk: () => {},

    // Number of times to reattempt retryable errors. Default 50.
    errorRetries: 50,
  }
)
.then(items => console.log(`Query returned ${items.length} item/s`))
.catch(err => console.error(err))
```

## Error handling
Errors are not caught by fullQuery as how they are handled is application specific. Therefore, please use `try...catch` syntax when using `async` syntax or the `.catch` method when using `Promise` syntax.

## API
`fullQuery(dbOptions, queryParams, [fullQueryParams])`

Performs a dynamodb query using the given db connection information and query options.

- `dbOptions` - an object passed to the AWS.DynamoDB constructor (see notes)
- `queryParams` - an object passed to the AWS.DynamoDB.query method (see notes)
- `fullQueryParams` - an object with options for the fullQuery call
  - `noReturn` - a boolean value indicating if results should be returned or not.
  - `onChunk` - a function which is processed for each chunk of items returned. Receives the same data object defined in the AWS.DynamoDB.query callback method (see notes).
  - `errorRetries` - a int value stating the number of times to retry retriable errors before throwing the error. Default 50.

## AWS References

1. [AWS.DynamoDB constructor options (first fullQuery parameter)][1]
1. [AWS.DynamoDB.query options (second fullQuery parameter)][2]

[1]: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#constructor-property
[2]: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#query-property

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