osdynamo
TypeScript icon, indicating that this package has built-in type declarations

1.0.16 • Public • Published

OSDynamo

OSDynamo is a tiny ORM typescript component made to facilitate Dynamo database handling

Install

yarn add osdynamo --save

Usage

Just declare your table with our decorators

import { OSDynamo, partitionKey, table } from 'osdynamo'

@table('CategoriesTable')
export class CategoryTable {

    @partitionKey() 
    public id: string

    public name: string

    public imageURL: string
}

...and then call the define method to get a reference to your model so you can save and retrieve data from Dynamo like this

const Category = OSDynamo.defineTable(CategoryTable)

Category.get({id: 'some id'}) // gets one category

Category.batchGet([ // gets multiple categories
    { id: 'some id' }, { id: 'another id' }, { id :'and so on...' }
])

Category.scan() // gets all categories from the table

Category.put({ id: '123', name: 'Fake category', imageURL: 'http://fakeimage.com'}) // writes a new item

Category.update({name: 'another fake name'}, {id: '123'})

Category.delete({id: '123'})

Current supported methods are:

  • get

  • batchGet (if it reaches Dynamo batchGet limit, this method splits into multiple parallel requests so you don't have to worry)

  • scan

  • put

  • batchWrite (if it reaches Dynamo batchWrite limit, this method splits into multiple parallel requests so you don't have to worry)

  • delete

  • query

IMPORTANT: dynamo region must be specified at node enviroment

More examples are coming!

CLI is coming

  • Commands like create and update table will we available soon

Want to contribute?

  • Whenever you face a bug or an uncovered use case, fix it in this same repository, so it can be published and used by other people :)

Readme

Keywords

none

Package Sidebar

Install

npm i osdynamo

Weekly Downloads

17

Version

1.0.16

License

ISC

Last publish

Collaborators

  • rudieros
  • lucasmafra