createTable
Spec
async createTable(): Promise<CreateTableOutput>;
Create table corresponding TynamoTable
.
When table is pre-exist, occur exception.
Output
Name
Type
Information
Example
@DynamoEntity({
TableName: "MyCatTable",
BillingMode: "PAY_PER_REQUEST"
})
class Cat {
@DynamoProperty({ keyType: KeyType.hash })
id!: number;
@DynamoProperty({ keyType: KeyType.attr })
name!: string;
@DynamoProperty({ keyType: KeyType.attr, dataType: DataType.NS })
favoriteNumbers!: number[];
constructor(id: number, name: string, favoriteNumbers: number[]) {
this.id = id;
this.name = name;
this.favoriteNumbers = favoriteNumbers;
}
}
const tynamo: Tynamo = new Tynamo({
region: "ap-northeast-2",
endpoint: "http://localhost:8000"
});
const tynamoTable: TynamoTable<Cat> = tynamo.getTableOf(Cat);
await tynamoTable.createTable();
Last updated
Was this helpful?