Enforces single table design on your DynamoDB queries in an elegant way.
A library to easily work with DynamoDB and enforces single table design approach.
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."
})
- Easy to use API to query and create items in DynamoDB.
- Data is automatically structured in single table design. `
npm install dynamometer # npm
yarn add dynamometer # yarn
pnpm add dynamometer # pnpm
Create a instance of the dynamometer client.
import { Dynamometer } from 'dynamometer';
const db = Dynamometer.create({
tableName: "dataTable"
})
A collection holds a number of items.
const collection = db.collection("USERS")
With a collection, items can be added to it or all can be queried.
collection.add({
name: "John Doe"
})
const reponse = await collection.get()
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"
})
A document is an item of a collection. It offers CRUD methodes.
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.
const doc = db.collection("USERS").doc("123")
const repsonse = await doc.set({
name: "John Doe"
})
const data = await doc.get()
const response = await doc.update({
name: "John Doester"
})
const response = await doc.delete()