Socket
Book a DemoInstallSign in
Socket

dynamodb-writer

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dynamodb-writer

Write items to DynamoDB in batches

0.0.2
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

dynamodb-writer

Build Status npm js-standard-style

Write items to DynamoDB in batches

save()

Save an item to internal queue. On 25th item (DynamoDB maximum), it will automatically call flush().

Important: A current limitation is that you cannot make successive calls to save() without waiting for callback first from each previous call to save().

flush()

This will be called internally by save() once internal queue is full. You should call this once after all save() calls are complete, to ensure internal queue is emptied.

Example

const async = require('async')
const {DynamoDB} = require('aws-sdk')
const DynamoDbWriter = require('dynamodb-writer')

const dynamodb = new DynamoDB({
  apiVersion: '2012-08-10'
})
const writer = DynamoDbWriter.create(dynamodb, {table: 'my-table'})
const items = []
async.eachSeries(items, (item, cb) => {
  // Important: You must wait for callback to be called
  // before calling `save()` again
  writer.save(item, cb)
}, (err) => {
  if (err) {
    return console.error('Failed to save items')
  }
  writer.flush((err) => {
    if (err) {
      return console.error('Failed to flush items')
    }
  })
})

Keywords

dynamodb

FAQs

Package last updated on 24 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.