dynamo1
v0.6.0
Published
Dynamo DB one table ORM for Javascript(& Typescript).
Downloads
7
Maintainers
Readme
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
- [x] Add GSI support to findOne, findMany in Repository
- [x] 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