Introduction
DynamoDB ORM for Typescript, most similar to AWS-SDK.
Tynamo
is decorator based data-mapper and ETL support library. Internally uses reflect-metadata. Since all API degins are similar to AWS-SDK
, you can use them most easily if you are already familiar with AWS-SDK.
@DynamoEntity()
class Cat {
@DynamoProperty({ keyType: KeyType.hash })
id!: number;
@DynamoProperty({ keyType: KeyType.sort })
age!: number;
@DynamoProperty({ keyType: KeyType.attr })
name!: string;
constructor(id: number, age: number, name: string) {
this.id = id;
this.age = age;
this.name = name;
}
}
// Create connection.
const tynamo: Tynamo = new Tynamo({
region: "ap-northeast-2",
endpoint: "http://localhost:8000"
});
// get table.
const catTable: TynamoTable<Cat> = tynamo.getTableOf(Cat);
// CreateTable then, PutItem.
// It is smillar to DynamoDB.putItem()
catTable.createTable();
catTable.putItem({
Item: new Cat(0, 0, "garfield"),
ConditionExpression: "attribute_not_exists(#id)"
});
Last updated
Was this helpful?