Define property

Define property

Write the @DynamoProperty decorator on top of the property definition. This property will be added to DynamoItem. And @DynamoEntity is can convert to AttributeMap.

@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;
    }
}

For example,

It will formationed as,

Key Type

Last updated

Was this helpful?