1.0.16 • Published 8 years ago
osdynamo v1.0.16
OSDynamo
OSDynamo is a tiny ORM typescript component made to facilitate Dynamo database handling
Install
yarn add osdynamo --saveUsage
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 :)