npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

dynamodb-lib

v1.0.6

Published

Library to simplify working with Dynamodb

Readme

Dynamodb-lib

This library was created to simplify work with AWS Dynamodb using generalized functions.

Installation

Use the package manager npm to install dynamodb-lib.

npm install dynamodb-lib

or

npm i dynamodb-lib

Usage

Set AWS configurations in environment variables:

export AWS_ACCESS_KEY_ID="Your AWS Access Key ID"
export AWS_SECRET_ACCESS_KEY="Your AWS Secret Access Key"
export AWS_REGION="us-east-1"

Here's a simple examples:

import {
  getItemByGSI,
  getAllItemsByGSI,
  updateInDB,
  writeDataIntoDB,
  removeAttributes,
  deleteItems,
  deleteItem
} from dynamodb-lib;

getItemByGSI => promise for returning Items from Dynamodb table using one query

getItemByGSIcan take following parameters:

TableName - Name of you Dynamodb table: required type String

IndexName - Name of you Index from Dynamodb table: optional type String

attribute - Key for query: required type String

value - Value for Key: required

sortKey - optional type String

sortValue - Value for SortKey: optional

filter - Filter for using in FilterExpression: optional type String

filterValue - Value for Filter: optional

operator - Operator for Filters if you have more then 1 filter. Required if you have filter1 and filterValue1: optional type String

filter1 - Second Filter for using in FilterExpression: optional type String

filterValue1 - Value for Filter1: optional

LastEvaluatedKey - Use LastEvaluatedKey for get next items. You can get LastEvaluatedKey from first request if You have more items in Table for one query : optional type Object

ScanIndexForward - Use ScanIndexForward for ordering items. For sure items be ordered if you have sort Key. ScanIndexForward: false for Descending. By default its Ascending: optional type Boolean

Limit - Use Limit for get Limited Items: optional type Number

Here's a simple example:

await getItemByGSI({
      TableName : 'Example',
      IndexName: 'favorite-createdAt-index',
      attribute: 'favorite',
      value: 'true',
      ScanIndexForward: false,
      Limit: 50
})

getAllItemsByGSI => promise for returning all Items from Dynamodb table using recursive queries

getAllItemsByGSIcan take same parameters as getItemByGSI.


writeDataIntoDB => promise for write record in Dynamodb table

writeDataIntoDBcan take following parameters:

TableName - Name of you Dynamodb table: required type String

Item - Object for insert to Dynamodb table: required type Object

Here's a simple example:

await writeDataIntoDB({
      TableName : 'Example',
      Item: {
         id: '9474d4f5-546f-447b-bdd8-a9cc27315e3d ',
         name: 'John',
         gender: 'male'
      }

})

updateInDB => promise for update record in Dynamodb table

updateInDBcan take following parameters:

TableName - Name of you Dynamodb table: required type String

Key - Object with Primary Key and Sort key if its be added in tables default index : required type Object updatedData - Object with data for update(its can update nested objects data to). Primary key and sort key cant be updated: required type Object

Here's a simple example:

await updateInDB({
      TableName : 'Example',
      Key: {id: 1, date: '12/12/2019'}
      updatedData: {
         name: 'John',
         gender: 'male',
         skills: {
          programming: 'Good'
         }
      }

})

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

GNU AGPL