0.6.0 • Published 4 years ago

dynamo1 v0.6.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Dynamo1

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

0.6.0

4 years ago

0.5.0

4 years ago

0.4.0

4 years ago

0.3.0

4 years ago

0.2.2

4 years ago

0.2.0

4 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago