dynamo-stream

1.0.1 • Public • Published

dynamo-stream

Promise based DynamoDB data streamer. It uses Dynamo DB Document client scan and query methods.

Install

$ npm install dynamo-stream

Basic Usage

const AWS = require('aws-sdk')
const createStreamClient = require('dynamo-stream')
 
const documentClient = new AWS.DynamoDB.DocumentClient()
const streamClient = createStreamClient(documentClient)
 
// Note: This function can return a promise that will be resolved before the
//       next item gets called
function onData(item) {
  console.log('Item: ', item)
}
 
streamClient.scan({ TableName: 'foo-table' }, onData).then(function() {
  // Note: This promise resolves when the method finishes streaming every
  //       item returned by the scan method.
  console.log('Finished')
})
 
queryTable = streamClient
  .query(
    {
      TableName: 'foo-table',
      KeyConditionExpression: '#user = :user',
      ExpressionAttributeValues: { ':user': 'foo-user' },
      ExpressionAttributeNames: { '#user': 'user' },
    },
    onData,
  )
  .then(function() {
    // Note: This promise resolves when the method finishes streaming every
    //       item returned by the query method.
    console.log('Finished')
  })

Readme

Keywords

none

Package Sidebar

Install

npm i dynamo-stream

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

5.45 kB

Total Files

5

Last publish

Collaborators

  • ndelvalle