Skip to content


The Table class is used to create an instance for each DynamoDB table you wish to access.

For each table, you define the table name, an AWS DynamoDB client connection object and a schema that defines your data model.

import {Table} from 'dynamodb-onetable'

const table = new Table({
    client: DocumentClientInstance,
    name: 'MyTable',
    schema: Schema,

The Table constructor takes a parameter of type object with the following properties:

Property Type Description
client DocumentClient An AWS DocumentClient instance.
crypto object Optional properties defining a crypto configuration to encrypt properties.
generate function Define a custom ID generator function that is used to create model IDs if required.
logger boolean|object Set to true to log to the console or set to a logging function(type, message, properties). Type is info
metrics object Configure metrics. Default null.
name string The name of your DynamoDB table.
schema string Definition of your DynamoDB indexes and models.
senselogs object Set to a SenseLogs logger instance instead logger. Default null.
transform function Callback function to be invoked to format and parse the data before reading and writing.
validate function Function to validate properties before issuing an API.
value function Function to evaluate value templates. Default null.

The client property must be an initialized AWS DocumentClient. The DocumentClient API is currently supported by the AWS v2 API. The recently released AWS v3 API does not yet support the DocumentClient API (stay tuned - See Issue).

By default, OneTable will not write null values to the database rather, it will remove the corresponding attribute from the item. If you set the nulls property to true, null values will be written via create or update. You can also define nulls on a model attribute basis via the schema.

The metrics property may be set to a map that configures detailed CloudWatch EMF metrics. See Metrics for more information.

The schema property must be set to your OneTable schema that defines your data model. See Schemas for details.

AWS DynamoDB Accelerator (DAX)

The Amazon DynamoDB Accelerator is a fully managed, highly available, in-memory cache for DynamoDB. OneTable supports DAX.

Currently, the AWS SDK V3 does not support DAX via by the DynamoDBClient package so you must use the AWS SDK V2.

Here is as sample initialization code for DAX:

import {DynamoDB} from 'aws-sdk'
import AmazonDaxClient from 'amazon-dax-client'

const endpoint = "dax://DAX-CLUSTER-ENDPOINT"
const dax = new AmazonDaxClient({endpoints: [endpoint], region: 'AWS_REGION'})

const client = new DynamoDB.DocumentClient({service: dax})