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

0.6.0 • Public • Published

Dynamo1

Build Downloads Version License Typescript
dependencies Status devDependencies Status

With Dynamo DB, only one table is enough.

Dynamo DB one table ORM for Javascript(& Typescript).

Installation

Usage

 
const connection = createConnection([
  {
    tableName: `${STAGE}-datas`,
    aliasName: 'datas',
    hashKey: { name: string, type: Buffer },
    rangeKey: { name: string, type: String },
    gsi: [
      { name: 'gsi1', hashKey: { name: string, type: String }, rangeKey: { name: string, type: String } },
      { name: 'gsi2', hashKey: { name: string, type: String }, rangeKey: { name: string, type: String } },
      { name: 'gsi3', hashKey: { name: string, type: String }, rangeKey: { name: string, type: String } },
    ],
  }, // tables[0] is default
])
 

Entity

import { v4 as uuid } from 'uuid'
 
import { Column, Entity, column, text } from 'dynamo1'
 
@Entity<User>({
  name: 'users',
  hashKey: text('users'),
  rangeKey: column('id'),
})
export class User {
  @Column({ name: 'user_id', onCreate: _ => uuid() })
  public id!: string
 
  @Column()
  public username?: string
 
  @Column()
  public email!: string
 
  @Column<User>({
    onCreate: entity => entity.createdAt || new Date().getTime(),
  })
  public createdAt!: number
 
  @Column<User>({
    onCreate: _ => new Date().getTime(),
    onUpdate: _ => new Date().getTime(),
  })
  public updatedAt!: number
}

Todo

  • Add GSI support to findOne, findMany in Repository
  • Add QueryBuilder, Repository createQueryBuilder method
  • Add Connection scan method
  • Add Repository count method
  • Logging
  • Index Full Type (buffer, string, number)
  • Add Connection updateItem method
  • Update Expression Builder (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html)
  • Multi tables
  • Define custom error types

Package Sidebar

Install

npm i dynamo1

Weekly Downloads

9

Version

0.6.0

License

MIT

Unpacked Size

179 kB

Total Files

118

Last publish

Collaborators

  • wan2land