@travetto/model-dynamodb

4.0.7 • Public • Published

DynamoDB Model Support

DynamoDB backing for the travetto model module.

Install: @travetto/model-dynamodb

npm install @travetto/model-dynamodb

# or

yarn add @travetto/model-dynamodb

This module provides an DynamoDB-based implementation for the Data Modeling Support. This source allows the Data Modeling Support module to read, write and query against DynamoDB. The entire document is stored as a single value, so nothing is needed to handle schema updates in real time. Indices on the other hand are more complicated, and will not be retroactively computed for new values.

Supported features:

  • CRUD
  • Expiry
  • Indexed Out of the box, by installing the module, everything should be wired up by default.If you need to customize any aspect of the source or config, you can override and register it with the Dependency Injection module.

Code: Wiring up a custom Model Source

import { InjectableFactory } from '@travetto/di';

import { DynamoDBModelService, DynamoDBModelConfig } from '@travetto/model-dynamodb';

export class Init {
  @InjectableFactory({ primary: true })
  static getModelService(conf: DynamoDBModelConfig) {
    return new DynamoDBModelService(conf);
  }
}

where the DynamoDBModelConfig is defined by:

Code: Structure of DynamoDBModelConfig

import type dynamodb from '@aws-sdk/client-dynamodb';

import { Config } from '@travetto/config';
import { Field } from '@travetto/schema';

@Config('model.dynamodb')
export class DynamoDBModelConfig {
  @Field(Object)
  client: dynamodb.DynamoDBClientConfig = {
    endpoint: undefined
  };
  autoCreate?: boolean;
  namespace?: string;
}

Additionally, you can see that the class is registered with the @Config annotation, and so these values can be overridden using the standard Configuration resolution paths.

Package Sidebar

Install

npm i @travetto/model-dynamodb

Homepage

travetto.io

Weekly Downloads

1

Version

4.0.7

License

MIT

Unpacked Size

20.6 kB

Total Files

7

Last publish

Collaborators

  • arcsine