sam-goodwin / punchcard

Type-safe AWS infrastructure.
Apache License 2.0
507 stars 20 forks source link

feat(dynamodb) consolidate HashTable and SortedTable into DynamoDB.Table #39

Closed sam-goodwin closed 5 years ago

sam-goodwin commented 5 years ago

Closes https://github.com/sam-goodwin/punchcard/issues/27

This change unifies the two DynamoDB types, HashTable and SortedTable, into DynamoDB.Table.

To declare a HashTable:

new DynamoDB.Table(stack, 'my-table', {
  partitionKey: 'id',
  shape: {
    id: string(),
    count: integer(),
  },
  billingMode: BillingMode.PAY_PER_REQUEST
});

A SortedTable has a sortKey defined:

new DynamoDB.Table(stack, 'my-table', {
  partitionKey: 'id',
  sortKey: 'count',
  shape: {
    id: string(),
    count: integer(),
  },
  billingMode: BillingMode.PAY_PER_REQUEST
});