Getting Started
Get started by installing Document Builder and its peer dependencies:
npm i dynamo-document-builder zod @aws-sdk/client-dynamodb @aws-sdk/lib-dynamodbpnpm add dynamo-document-builder zod @aws-sdk/client-dynamodb @aws-sdk/lib-dynamodbyarn add dynamo-document-builder zod @aws-sdk/client-dynamodb @aws-sdk/lib-dynamodbDefine your Table
Section titled “Define your Table”Document Builder follows Single Table design, to get started we’ll first need to define our table:
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';import { DynamoTable } from 'dynamo-document-builder';
const dynamoClient = new DynamoDBClient();const documentClient = DynamoDBDocumentClient.from(dynamoClient);
const exampleTable = new DynamoTable({ name: 'ExampleTable', documentClient, keyNames: { partitionKey: 'PK', sortKey: 'SK', },});Now that we have our table, we can define the entities that belong to it.