0.0.5 • Published 5 years ago

dynamodb-scan v0.0.5

Weekly downloads
19
License
MIT
Repository
github
Last release
5 years ago

dynamodb-scan

Travis Build NPM Version NPM Downloads

EventEmitter to simplify dynamodb parallel scans

Features

  • EventEmitter pattern for dynamodb scan
  • Data event emitted for each record
  • Supports pause/resume of emitter
  • DynamoDb parallel scans supported

Installation

  $ npm install dynamodb-scan --save

Usage

'use strict';

var DynamoDbScan = require('dynamodb-scan');


var dynamoDbScan = new DynamoDbScan('awsAccessKey', 'awsSecret', 'awsRegion', 'tableName');

var count = 0;

dynamoDbScan.on('data', function(item) {
    count++;
    console.dir(item);

    if(count === 10)
    {
        dynamoDbScan.pause();

        setTimeout(function() {
            dynamoDbScan.resume();
        }, 5000);
    }
});

dynamoDbScan.on('finish', function() {
    console.info('Finish');
    process.exit(0);
});

dynamoDbScan.start();

Parallel Scans are useful to maximize usage of throughput provisioned on the DynamoDb table.

Documentation

new DynamoDbScan(awsAccessKeyId, awsSecretAccessKey, awsRegion, tableName, options)

Sets up the AWS credentials to use

Arguments

  • awsAccessKeyId - AWS access key if not provided falls back to whatever AWS SDK can find
  • awsSecretAccessKey - AWS secret if not provided falls back to whatever AWS SDK can find
  • awsRegion - AWS region if not provided falls back to whatever AWS SDK can find
  • tableName - Name of table to scan
  • options - Options
    • parallelScans - Number of parallel scans to run. Defaults to 1
    • maxRetries - Number of times to retry a failed dynamo db operation. Passed to aws-sdk.

start()

Starts the scan. Method available so you can hook up your listeners before it starts emitting events.

pause()

Pauses a scan. Events may still be emitted from the previous scan operation.

resume()

Resumes a paused scan.

paused()

Returns true if emitter is paused

People

The author is Chris Kinsman from PushSpring

License

MIT

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago