Git Product home page Git Product logo

dynamaster's Introduction

DynaMaster 🧨

🚧 WORK IN PROGRESS 🚧

🪶Lightweight and 🔐Typed interaction with DynamoDB

For information on Dynamo SDK, visit their docs

Why I wrote this library:

  • I think it is strange that number is passed as a string in the SDK
  • I don't think is convenient that binary SDK requires the user to pass in the binary instead of a string
  • I think the keys used to index the AttributeValue are confusing (i.e. S, SS, M, etc.)
  • The creation of a Map is very confusing and verbose

🎯 The goal

Write the smallest typed library that interfaces with DynamoDB using native TS variables and objects.

Features

  • It can convert JS or TS variables to DynamoDB AttributeValue
  • boolean implemented
  • null implemented
  • number implemented
  • string implemented
  • binary implemented
  • Set(number) implemented
  • Set(string) implemented
  • Set(binary) implemented
  • list missing
  • map missing
  • unknown missing

Usage

import { AttrType, writeToItem } from "dynamaster";
import {
  BatchWriteItemCommand,
  BatchWriteItemCommandOutput,
  DynamoDBClient,
  WriteRequest,
} from '@aws-sdk/client-dynamodb';

// string 👇
const myStringItem = writeToItem({
  type: AttrType.STRING,
  colName: "myColumnName",
  value: "payload"
})

// number 👇
const myNumberItem = writeToItem({
  type: AttrType.NUMBER,
  colName: "myColumnName",
  value: 123
})

// boolean 👇
const myBoolItem = writeToItem({
  type: AttrType.BOOLEAN,
  colName: "boolColFalse",
  value: false,
})

const tableName = "yourTableName"
const input = {
  "RequestItems": {
    [tableName]: [
      //                        👇            👇            👇
      { "PutRequest": { "Item": myStringItem, myNumberItem, myBoolItem } }
    ]
  }
}
const command = new BatchWriteItemCommand(input);
await client.send(command);

dynamaster's People

Watchers

 avatar

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.