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 🙏

© 2026 – Pkg Stats / Ryan Hefner

node-dynamodb-utils

v1.0.8

Published

Utility functions for DynamoDB operations using AWS SDK v3

Readme

dynamoDBUtils

A lightweight, TypeScript-based utility package for simplifying DynamoDB operations using AWS SDK v3. This package provides essential DynamoDB functionalities, including caching, query building, and transactional operations, with input validation powered by Zod.


Features

  • CRUD Operations: Simplified functions for getItem, insertItem, updateItem, and more.
  • Table Management: Easily manage tables with listTables, createTable, describeTable, and deleteTable.
  • Caching: Built-in ephemeral caching with TTL support to optimize performance.
  • Advanced Querying: Query and scan operations with reusable query builders.
  • Input Validation: Integrated with Zod for strong input validation.
  • TypeScript Support: Fully typed for better developer experience and safety.

Installation

Install the package via npm:

npm install dynamoDBUtils

Usage

Setup

Before using the package, ensure you have AWS credentials configured in your environment or ~/.aws/credentials.

import { getItem, updateItem, scanTable } from "dynamoDBUtils";

Basic Examples

Get an Item

import { getItem } from "dynamoDBUtils";

const result = await getItem("UsersTable", { userId: "123" });
console.log(result);

Get an Item with Cache

import { getItemWithCache } from "dynamoDBUtils";

const result = await getItemWithCache(
  "UsersTable",
  { userId: "123" },
  ["name", "email"],
  10
); // Cache for 10 minutes
console.log(result);

Update an Item

import { updateItem } from "dynamoDBUtils";

const result = await updateItem(
  "UsersTable",
  { userId: "123" },
  { name: "John Doe" }
);
console.log(result);

Scan a Table

import { scanTable } from "dynamoDBUtils";

const result = await scanTable("UsersTable", { isActive: true });
console.log(result);

Batch Get Items

import { batchGet } from "dynamoDBUtils";

const result = await batchGet("UsersTable", [
  { userId: "123" },
  { userId: "456" },
]);
console.log(result);

Advanced Operations

Transactional Write

import { transactWrite } from "dynamoDBUtils";

const result = await transactWrite({
  TransactItems: [
    {
      Put: {
        TableName: "UsersTable",
        Item: { userId: "789", name: "Alice" },
      },
    },
    {
      Update: {
        TableName: "UsersTable",
        Key: { userId: "123" },
        UpdateExpression: "SET #name = :name",
        ExpressionAttributeNames: { "#name": "name" },
        ExpressionAttributeValues: { ":name": "John Updated" },
      },
    },
  ],
});
console.log(result);

Query Table

import { queryTable } from "dynamoDBUtils";

const result = await queryTable({
  TableName: "UsersTable",
  KeyConditionExpression: "userId = :userId",
  ExpressionAttributeValues: { ":userId": "123" },
});
console.log(result);

Table Management

List Tables

import { listTables } from "dynamoDBUtils";

const tables = await listTables();
console.log(tables);

Create a Table

import { createTable } from "dynamoDBUtils";

const result = await createTable({
  TableName: "NewTable",
  KeySchema: [{ AttributeName: "id", KeyType: "HASH" }],
  AttributeDefinitions: [{ AttributeName: "id", AttributeType: "S" }],
  ProvisionedThroughput: {
    ReadCapacityUnits: 5,
    WriteCapacityUnits: 5,
  },
});
console.log(result);

Query Builder

Create reusable query objects dynamically with the QueryBuilder utility.

import { QueryBuilder } from "dynamoDBUtils";

const query = new QueryBuilder("UsersTable")
  .addKeyCondition("userId", "=", "123")
  .addFilter("isActive", "=", true)
  .addProjection("name", "email")
  .setLimit(10)
  .build();

console.log(query);

Validation

This package uses Zod to validate inputs. Incorrect inputs will throw validation errors, helping to prevent runtime issues.


Configuration

Cache Directory

For Lambda, cache is stored in /tmp. For other environments, ensure the process has write access to a directory for caching.


Contributing

Feel free to submit issues and pull requests on GitHub to improve this package.


License

This project is licensed under the MIT License.


Support

If you encounter any issues, feel free to open a GitHub issue or reach out to the maintainers.