Define entity

Define entity

Write the @DynamoEntity decorator on top of the class definition.

@DynamoEntity()
class Cat {
    ...
}

With table attribute

Also you can put table information into @DynamoEntity. This information is used to table transaction.

@DynamoEntity({
    BillingMode: "PAY_PER_REQUEST",
    ProvisionedThroughput: {
        ReadCapacityUnits : 15, // default 5
        WriteCapacityUnits: 20  // default 5
    }
})
class Cat {
    ...
}

new Tynamo(...).createTable(Cat);
new Tynamo(...).deleteTable(Cat);
new Tynamo(...).describeTable(Cat);

The parameter details are as follows :

export interface TableInformation {
    TableName?: TableName;
    LocalSecondaryIndexes?: LocalSecondaryIndexList;
    GlobalSecondaryIndexes?: GlobalSecondaryIndexList;
    BillingMode?: BillingMode;
    ProvisionedThroughput?: ProvisionedThroughput;
    StreamSpecification?: StreamSpecification;
    SSESpecification?: SSESpecification;
    Tags?: TagList;
}

This design is derived from AWS.CreateTable.

Check here for more information.

Last updated

Was this helpful?