0.2.10-alpha.0 • Published 9 months ago

serverless-cqrs.dynamodb-adapter v0.2.10-alpha.0

Weekly downloads
9
License
ISC
Repository
github
Last release
9 months ago

dynamodb-adapter

A library that implements the Write Model Adapter interface for storing events on dynamodb.

Here's an example of the table config in CloudFormation syntax:

    EventStoreTable:
      Type: 'AWS::DynamoDB::Table'
      Properties:
        TableName: someEntity ## <- your table name here
        AttributeDefinitions: 
          - AttributeName: entityId
            AttributeType: S
          - AttributeName: version
            AttributeType: N
          - AttributeName: entityName
            AttributeType: S
          - AttributeName: commitId
            AttributeType: S
        KeySchema:
          - AttributeName: entityId
            KeyType: HASH
          - AttributeName: version
            KeyType: RANGE
        GlobalSecondaryIndexes:
        - IndexName: someEntityByCommitId ## <- your index name here
          KeySchema:
          - AttributeName: entityName
            KeyType: HASH
          - AttributeName: commitId
            KeyType: RANGE
          Projection:
            ProjectionType: ALL

Methods

build

build({ entityName }, { tableName, indexName, ...awsOptions )

builds a write model adapter

Parameters

attributetypedescription
entityNamestringthe name of the entity
tableNamestringthe name of the dynamodb table
indexNamestringthe name of the index sorting commits by commitId
...awsOptionsobjectany additional arguments are passed along to AWS, like so:new AWS.DynamoDB(awsOptions)

Returns

an object with write model methods

Example

const dynamoAdapterBuilder = require('serverless-cqrs.dynamodb-adapter')
module.exports = dynamoAdapterBuilder.build({ 
  entityName: 'todo'
}, {
  tableName: 'todos',
  indexName: 'todosByCommitId',
  region: 'eu-west-1',
})
0.2.10-alpha.0

9 months ago

0.2.7-alpha.0

5 years ago

0.2.6-alpha.0

5 years ago

0.2.3-alpha.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.2

6 years ago

1.0.0

6 years ago