Code Monkey home page Code Monkey logo

dynamometer's Introduction

Dynamometer

Dynamometer logo

Dynamometer


Enforces single table design on your DynamoDB queries in an elegant way.

npm package Build Status Downloads Issues Code Coverage Commitizen Friendly Semantic Release

A library to easily work with DynamoDB and enforces single table design approach.

Introduction

Inspired by Firestore SDK.

Managing your data with a single design approach in DynamodDB can sometimes be difficult. Dynamometer uses so-called "Collections" and "Docs" to structure your data in an comprehensible way.

Dynamometer is intended for simple, low-complexity projects and is designed to allow an architect to immediately take a single-table approach with a DynamoDB table without having to think much about access patterns.

const db = Dynamometer.create({
  tableName: "dataTable"
})

db.collection('USERS')
  .doc("xspvLRiJ")
  .collection("TODOS")
  .add({
    text: "Makes managing your data a breeze."
  })

Features


  • Easy to use API to query and create items in DynamoDB.
  • Data is automatically structured in single table design. `

Install

Install


npm install dynamometer       # npm
yarn add dynamometer          # yarn
pnpm add dynamometer          # pnpm

Usage

Basic usage


Create a instance of the dynamometer client.

import { Dynamometer } from 'dynamometer';

const db = Dynamometer.create({
  tableName: "dataTable"
})

CollectionReference

A collection holds a number of items.

Creating a collection

const collection = db.collection("USERS")

With a collection, items can be added to it or all can be queried.

Adding an item

collection.add({
  name: "John Doe"
})

Query all Items

const reponse = await collection.get()

Doc

If you know the ID of an item in the collection or you want to give it your own ID you can use the doc methode.

// get the doc
collection.doc("123").get()

// add the doc with the id 123
collection.doc("123").add({
  name: "John Doe"
})

DocumentReference

A document is an item of a collection. It offers CRUD methodes.

Doc

If you know the ID of an item in the collection or you want to give it your own ID you can use the doc methode.

Creating a document

const doc = db.collection("USERS").doc("123")

Set doc data

 const repsonse = await doc.set({
  name: "John Doe"
})

Get doc data

const data = await doc.get()

Update doc

const response = await doc.update({
  name: "John Doester"
})

Delete doc

const response = await doc.delete()

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.