DynamoDB Connector
![Build Status](../../workflows/CICD/badge.svg)
Provides a standardized way to connect to an AWS DynamoDB database using the v3 AWS javascript SDK.
Install
npm install @brightcove/dynamodb-connector --save
Usage
Version 2.x
const { DynamoDBConnector } = require('@brightcove/dynamodb-connector');
// Localstack configuration example
const db = new DynamoDBConnector({
clientConfig: {
endpoint: 'http://localhost:4566,
region: 'us-east-1'
}
});
...
const result = await db.query({
TableName: 'my-table',
...
});
Options
Version 3.x
This version includes breaking changes by requiring the DynamoDBDocument
to be passed in as an option. This drasticaly reduces the size of this package and removes all external dependencies.
import { DynamoDBDocument } from '@aws-sdk/lib-dynamodb';
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
import { DynamoDBConnector } from '@brightcove/dynamodb-connector';
const client = new DynamoDBClient({
endpoint: 'http://localhost:4566',
region: 'us-east-1'
});
const document = DynamoDBDocument.from(client);
const db = new DynamoDBConnector({ document });
...
const result = await db.query({
TableName: 'my-table',
...
});
Options