JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q40098F
  • License MIT

dynamo-record provides a DynamoDB client that adds Promise support and functionality beyond what is provided by the aws-sdk.

Package Exports

  • dynamo-record

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dynamo-record) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Dynamo Record

This package aims to provide an “humanize" and more readable support of DynamoDB DocumentClient.

Getting started

Installation

$ npm install dynamo-record --save

OR

$ yarn add dynamo-record

Import & initialization

// assumes AWS.config is set up already
import { DynamoRecord } from "dynamo-record";

const repo = new DynamoRecord(
    tableName,
    tableRegion
);

Key concept

The library generates the DynamoDB config for you.

In some cases where a method will not allow you to accomplish what you would like, each method has an optional params config where you can override each DocumentClient basic params. API documentation specify which basic method from DocumentClient is extended.

In Dynamo Record, all params for config are camelize (fooBar) key insteaf of pascalize (FooBar).

API

The following methods are available. All DocumentClient methods are not already implemented

find

Return a single element based on his primary key

repo.find(primaryKey, config)

Extend: get()

Parameters

  • primaryKey object with hash and range key. Provided keys must match dynamoDB schema.
  • config optional - object with DocumentClient params.

where

Return all items that match primary key and/or condition

repo.where(primaryKey, filterExpression, config)

Extend: query() scan()

Parameters

  • primaryKey optional - object with hash and range key. Provided keys must match dynamoDB schema.
  • filterExpression optional - object with required condition and keys property.
  • config optional - object with DocumentClient params.

getAll

Return all items

repo.getAll(config)

Extend: scan()

Parameters

  • config optional - object with DocumentClient params.

create

Add a new item

repo.create(createData, config)

Extend: put()

Parameters

  • createData object with data to add into table.
  • config optional - object with DocumentClient params.

update

Update an item based on his primary key

repo.update(primaryKey, updateData, config)

Extend: update()

Parameters

  • primaryKey object with hash and range key. Provided keys must match dynamoDB schema.
  • updateData object with item data to update.
  • config optional - object with DocumentClient params.

destroy

Remove an item

repo.delete(primaryKey, config)

Extend: delete()

Parameters

  • primaryKey object with hash and range key. Provided keys must match dynamoDB schema.
  • config optional - object with DocumentClient params.