https://github.com/mattjennings/dynamodb-table-client
A DocumentClient wrapper for single table design and better typescript support
https://github.com/mattjennings/dynamodb-table-client
Last synced: 23 days ago
JSON representation
A DocumentClient wrapper for single table design and better typescript support
- Host: GitHub
- URL: https://github.com/mattjennings/dynamodb-table-client
- Owner: mattjennings
- License: mit
- Created: 2021-01-09T20:37:17.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-01-09T20:49:10.000Z (over 4 years ago)
- Last Synced: 2025-04-08T19:31:47.072Z (2 months ago)
- Language: TypeScript
- Size: 151 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dynamodb-table-client
A DocumentClient wrapper for single table design and better typescript support.
For the most part, the API is the same as DocumentClient aside from having to provide the TableName for each request.
`batchGet` and `batchWrite` have a slightly different API because they don't need to be concerned with multiple tables.# Install
```bash
npm install dynamodb-table-client
```# Usage
```typescript
import { TableClient } from 'dynamodb-table-client';// common attributes between all items
interface DynamoDBItem {
// this is where you would type your Key and GSI schemas
PK: string;
SK: string;
GSI1PK?: string;
GSI1SK?: string;// but you could use it for common meta atts as well
created: string;
}const tableClient = new TableClient({
tableName: `my-table`,
region: `us-east-1`,
});interface Note extends DynamoDBItem {
title: string;
}await tableClient.put({
Item: {
PK: 'NOTE#1',
SK: 'META',
created: new Date().toISOString(),
title: 'My Note',
},
});const note = await tableClient.get({
Key: {
PK: 'NOTE#1',
SK: 'META',
},
});
```