npm.io
0.20.25 • Published 7 years ago

resolve-storage-dynamo

Licence
MIT
Version
0.20.25
Deps
3
Size
181 kB
Vulns
0
Weekly
0
Stars
772

resolve-storage-dynamo

npm version

This package is a resolve-es adapter for storing events using DynamoDB.

Available Parameters

  • ...connectionOptions - a DynamoDB connection options. Refer to Connection Options Format for more information.
  • tableName - a name of a table storing events.
  • billingMode - billing mode for dynamodb table.
  • readCapacityUnits - the maximum number of strongly consistent reads consumed per second.
  • writeCapacityUnits - the maximum number of writes consumed per second.

Usage

[PROVISIONED] Billing Mode
import createAdapter from 'resolve-storage-dynamo'

const connectionOptions = {
  region: 'localhost',
  endpoint: 'http://localhost:8000',
  accessKeyId: 'xxx',
  secretAccessKey: 'xxx',
}

const adapter = createAdapter({
  ...connectionOptions,
  tableName: 'MY_TABLE_NAME',
  billingMode: 'PROVISIONED',
  readCapacityUnits: 5,
  writeCapacityUnits: 5
})
[PAY_PER_REQUEST] Billing Mode
import createAdapter from 'resolve-storage-dynamo'

const connectionOptions = {
  region: 'localhost',
  endpoint: 'http://localhost:8000',
  accessKeyId: 'xxx',
  secretAccessKey: 'xxx',
}

const adapter = createAdapter({
  ...connectionOptions,
  tableName: 'MY_TABLE_NAME'
})
As Resource
import { create, dispose, destroy, waitForCreate } from 'resolve-storage-dynamo'

const lazyResource = await create({ 
  region,
  tableName, 
  readCapacityUnits, 
  writeCapacityUnits 
})

await waitForCreate(lazyResource)

await dispose({ 
  region,
  tableName, 
  newTableName, 
  readCapacityUnits, 
  writeCapacityUnits 
})

await destroy({ 
  region,
  tableName, 
  readCapacityUnits, 
  writeCapacityUnits 
})

Analytics

Keywords