dynamo-update-expr
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

dynamo-update-expr

Simple DynamoDB update expression generator.

As of now there is only support for DynamoDB SET expression. I will try to maintain this repository and add support for ADD, REMOVE, DELETE expressions as well

Installation

  npm i dynamo-update-expr

Usage

  const { DynamoExpression }=require('dynamo-update-expr')

  const values = [
    {
      key: 'user.name.first',
      value: 'John'
    },
    {
      key: 'user.name.last',
      value: 'Doe'
    },
    {
      key: 'user.data',
      value: {
        age: 24,
        location: 'Manglore'
      }
    },
    {
      key: 'name',
      value: 'Shashank'
    }
  ]

  let expr = new DynamoExpression().set(values);

  console.log(expr.asExpression());

Methods

set

function to generate a DynamoExpression which will SET some values in the DB

Parameters

  • items Array<SetParam> Array od setParams to the DynamoExpression

Returns DynamoExpression expr

Type - SetParam
  interface SetParam {
    key: string;
    value: any;
  }

asExpression

function to get the expression object to directly pass to the Dynamodb update call

Returns Expression generated dynamo expression

Type - Expression
  interface Expression {
    ExpressionAttributeNames: Record<string,any>;
    ExpressionAttributeValues: Record<string,any>;
    UpdateExpression: string;
  }

Please feel free to create pull requests or feature requests.

Package Sidebar

Install

npm i dynamo-update-expr

Weekly Downloads

2

Version

1.0.2

License

ISC

Unpacked Size

8.19 kB

Total Files

8

Last publish

Collaborators

  • shashank-harikripa