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 🙏

© 2024 – Pkg Stats / Ryan Hefner

dynamodb-toolbox

v1.13.4

Published

Lightweight and type-safe query builder for DynamoDB and TypeScript.

Downloads

191,496

Readme

dynamodb-toolbox

💖 Huge thanks to the sponsors who help me maintain this repo:

DynamoDB-Toolbox



DynamoDB-Toolbox is a light abstraction layer over the DocumentClient that turns your DynamoDB journey into a ✨ bliss ✨

Features

🤗 Simpler queries: DynamoDB-Toolbox does all the heavy-lifting of crafting those complex DynamoDB requests. It makes your code clearer, more concise and easier to maintain.

📐 Data validation: Both pushed and fetched items are validated against your schemas, which guarantees the consistency of your data and the reliability of your code.

A rich schema syntax that supports a broad range of edge cases like defaults, composition, transformation and polymorphism.

🌈 Type-safety pushed to the limit: Increase your development velocity with instantaneous feedbacks and slick auto-completion.

🌴 Tree-shakable: Only import what you need.

☝️ Single-table designs: DynamoDB-Toolbox makes querying multiple entities within the same table extremely simple, although it works just as well with multiple tables.

🪶 LLRT compatible: DynamoDB-Toolbox has no dependency and can be used within LLRT functions.

Visit the 👉 official documentation 👈 to get started!

Why use it?

If you're here, we're assuming you know DynamoDB.

If you don't, check out the official AWS docs.

TLDR: DynamoDB is a key-value DB designed to run high-performance applications at any scale. It automatically scales up and down based on your current traffic, and removes the need to maintain connections, which makes it the go-to DB for many projects, including (but not limited to) serverless applications.

If you've ever used the official Document Client, you know that it’s painful to use.

Take a look at this UpdateCommand example straight from the AWS documentation:

await documentClient.send(
  new UpdateCommand({
    TableName: 'Music',
    Key: {
      // 👇 No type-safety on the Primary Key
      artist: 'Acme Band',
      songTitle: 'Happy Day'
    },
    // 👇 Complex string expressions (+ still no type-safety)
    UpdateExpression: 'SET #Y = :y, #AT = :t',
    // 👇 Attribute names provided separately
    ExpressionAttributeNames: {
      '#AT': 'albumTitle',
      '#Y': 'year'
    },
    // 👇 Attribute values as well
    ExpressionAttributeValues: {
      // 👇 No validation or type-safety to enforce DB schema
      ':t': 'Louder Than Ever',
      ':y': '2015'
    },
    ReturnValues: 'ALL_NEW'
  })
)

It's a very simple example (updating two fields of a Music item), yet already complex 😰

Things only get messier as your data grows in complexity: What if your items have many attributes, with some of them deep or optional? What if you need to index an item based on its value or handle different types of items? What about polymorphism?

In those cases, which are fairly common, the required code to generate those requests gets very hard to maintain. That's when DynamoDB-Toolbox comes to the rescue 💪

Here's is a quick preview with the DynamoDB-Toolbox version of the UpdateCommand described above:

// Validated AND type-safe syntax 🙌
await MusicEntity.build(UpdateItemCommand)
  .item({
    artist: 'Acme Band',
    songTitle: 'Happy Day',
    albumTitle: 'Louder Than Ever',
    year: '2015'
  })
  .options({ returnValues: 'ALL_NEW' })
  .send()

And just like that, we went from an obscure 20 lines to a readable and elegant 10-liner 🤩

Not bad, eh? Let's get started!

Become a Sponsor!