dynamodb-iterator

1.0.0 • Public • Published

dynamodb-iterator

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

Install

$ npm install dynamodb-iterator

Basic Usage

const AWS = require('aws-sdk')
const createIterator = require('dynamodb-iterator')
 
const documentClient = new AWS.DynamoDB.DocumentClient()
const iterator = createIterator(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)
}
 
iterator.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 = iterator
  .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 dynamodb-iterator

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

5.48 kB

Total Files

5

Last publish

Collaborators

  • ndelvalle