0.10.0 • Published 4 months ago

@crster/dynamo-blade v0.10.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Dynamo Blade

Simple dynamodb client with single table design

#Not yet for production use

To Use

import DynamoBlade from "@crster/dynamo-blade";
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";

const db = new DynamoBlade({
  tableName: "simple",
  client: new DynamoDBClient({
    region: "local",
    endpoint: "http://localhost:8000",
  }),
});

To Initialize table

const result = await db.init()

To Add

const result = await db.open("artist").add("john", {
    name: "John Doe",
    age: 10,
  });

To Get

const result = await db.open("artist").is("john").get();

console.log(result.getItem())

To Add separate property

const result = await db.open("artist").is("john").open("album").add("j2", {
    title: "J2",
    price: 150,
    rating: 3,
  });

To get all albums as array

const result = await db.open("artist.album").get()
console.log(result.getItems())

To Update

const result = await db
    .open("artist")
    .is("john")
    .open("album")
    .is("love1")
    .set({ price: 210 });

To use transaction

for mutation only

await db
  .open("artist")
  .is("001")
  .open("album")
  .is("ab001")
  .set({ songCount: 0 });

const artistAlbumnDb = db.open("artist").is("001").open("album").is("ab001");

const commands = artistAlbumnDb.open("song").is("s1").when("hasCollab", "=", true), artistAlbumnDb.open("song").addLater("s6", { title: "Song Number 6", genre: "Reggae", length: 4.5, hasCollab: false, }), artistAlbumnDb.setLater({ songCount: 4, }), ;

await db.transact(commands); // use this to execute the transaction

const result = await artistAlbumnDb.get(); const success = result.getItem().songCount === 4 // the transaction succeed

0.10.0

4 months ago

0.9.0

4 months ago

0.9.1

4 months ago

0.8.0

9 months ago

0.7.0

9 months ago

0.6.4

9 months ago

0.6.3

9 months ago

0.6.2

9 months ago

0.6.1

9 months ago

0.6.0

9 months ago

0.5.0

10 months ago

0.4.4

10 months ago

0.4.3

10 months ago

0.4.2

10 months ago

0.4.1

10 months ago

0.4.0

10 months ago

0.3.0

10 months ago

0.2.2

10 months ago

0.2.1

10 months ago

0.2.0

10 months ago

0.1.2

10 months ago

0.1.1

10 months ago

0.1.0

10 months ago