@alphax/dynamodb
TypeScript icon, indicating that this package has built-in type declarations

1.2.13 • Public • Published

DynamoDB Helper

Installation

yarn add @alphax/dynamodb
or
npm i @alphax/dynamodb

Feature

  • Bulk Insert and Trancate
  • Easy implement for database query
  • Query Logging with log4js
  • Option to tracing with AWS X-Ray
  • CLI commands

Usage

import { DynamodbHelper } from '@alphax/dynamodb';

const helper = new DynamodbHelper({
  logger: {
    appenders: { console: { type: 'console' } },
    categories: { default: { appenders: ['console'], level: 'info' } },
  },
  options: {
    endpoint: 'http://localhost:8001',
    region: 'ap-northeast-1',
  },
});

(async () => {
  const tableName = 'TableName';

  // scan
  const results = await helper.scan({
    TableName: tableName,
  });

  // truncateAll
  await helper.truncateAll(tableName);

  // if exists
  if (results.Items) {
    // bulk insert
    await helper.bulk(tableName, results.Items);
  }
})();

Methods

Name Description
scan Scan items promise
scanRequest Scan item request
query Query item promise
queryRequest Query item request
get Get item promise
getRequest Get item request
put Put item promise
putRequest Put item request
update Update item promise
updateRequest Update item request
delete Delete item promise
deleteRequest Delete item request
truncateAll truncate all records
truncate truncate records with inputs
bulk Insert all records

Readme

Keywords

none

Package Sidebar

Install

npm i @alphax/dynamodb

Weekly Downloads

5

Version

1.2.13

License

MIT

Unpacked Size

88.4 kB

Total Files

24

Last publish

Collaborators

  • wwalpha