resolve-storage-dynamo
v0.20.25
Published
This package serves as an adapter for resolve-storage to store events using DynamoDB.
Downloads
24
Readme
resolve-storage-dynamo
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
})