Giter Club home page Giter Club logo

dynamodb-toolbox



πŸ’– Huge thanks to the sponsors who help me maintain this repo:

TheodoΒ Β  Feathers CloudΒ Β lijiananΒ Β Raees IqbalΒ Β SentryΒ Β Lucas Saldanha FerreiraΒ Β  Plus sign

DynamoDB-Toolbox


Light-weight and type-safe
query builder for DynamoDB and TypeScript.


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.

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, some nested 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!

DynamoDB Toolbox's Projects

DynamoDB Toolbox doesn’t have any public repositories yet.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.