0.0.7 • Published 12 months ago

@bippo-nest/dynamodb-doc-client v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

dynamodb-doc-client

AWS DynamoDB Document Client module for Nest.

Installation

$ npm install --save @bippo-nest/dynamodb-doc-client

Quick Start

1. Add import into your app module

src/app.module.ts

import { Module } from '@nestjs/common';

import { AppController } from './app.controller';
import { AppService } from './app.service';

import { DynamoDBDocClientModule } from '@bippo-nest/dynamodb-doc-client';

@Module({
  imports: [DynamoDBDocClientModule.forRoot()],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}

forRoot() optionally accepts the following objects in this order: DynamoDBClientConfig, marshallOptions, unmarshallOptions

2. Inject and use your model

src/app.service.ts

import { Injectable } from '@nestjs/common';

import { DynamoDBDocClientService } from '@bippo-nest/dynamodb-doc-client';

@Injectable()
export class AppService {
  constructor(private readonly docClient: DynamoDBDocClientService) {}

  async createData() {
    const params = {
      TableName: 'MyTable',
      Item: {
        pk: 'myPK',
        sk: '001',
        foo: 17,
        bar: 'what a wonderful day',
      },
    };
    try {
      await this.docClient.clientPut(params);
    } catch (error) {
      console.log(error);
    }
  }
}

Pass-Through Methods

All methods that start with the client prefix pass arguments directly to the document client

0.0.7

12 months ago

0.0.2

1 year ago

0.0.1

1 year ago