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.
The Table constructor takes a parameter of type
object with the following properties:
||An AWS DocumentClient instance.|
||Optional properties defining a crypto configuration to encrypt properties.|
||Define a custom ID generator function that is used to create model IDs if required.|
||Set to true to log to the console or set to a logging function(type, message, properties). Type is info|
||Configure metrics. Default null.|
||The name of your DynamoDB table.|
||Definition of your DynamoDB indexes and models.|
||Set to a SenseLogs logger instance instead
||Callback function to be invoked to format and parse the data before reading and writing.|
||Function to validate properties before issuing an API.|
||Function to evaluate value templates. Default null.|
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
update. You can also define
nulls on a model attribute basis via the schema.
metrics property may be set to a map that configures detailed CloudWatch EMF metrics. See Metrics for more information.
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: