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