How to use the @ddes/core.VersionConflictError function in @ddes/core

To help you get started, we’ve selected a few @ddes/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Skalar / ddes / packages / @ddes / aws-store / lib / AwsEventStore.ts View on Github external
public async commit(commit: Commit) {
    try {
      await this.dynamodb
        .putItem({
          TableName: this.tableName,
          Item: await utils.marshallCommit(commit),
          ConditionExpression: 'attribute_not_exists(v)',
          ReturnValues: 'NONE',
        })
        .promise()
    } catch (error) {
      if (error.code === 'ConditionalCheckFailedException') {
        throw new VersionConflictError(
          `${commit.aggregateType}[${
            commit.aggregateKey
          }] already has a version ${commit.aggregateVersion} commit`
        )
      }

      throw error
    }
  }

@ddes/core

Event Sourcing in TypeScript

MIT
Latest version published 3 months ago

Package Health Score

65 / 100
Full package analysis