DataType

Supported data type

Type

Full name

Require

N

Number

number

S

String

string

B

Binary

Buffer

BOOL

Boolean

boolean

NS

Number Set

number[ ]

SS

String Set

string[ ]

BS

Binary Set

Buffer[ ]

L

List

@DynamoEntity[ ] | Number[ ] | String[ ] | Boolean[ ]

M

Map

@DynamoEntity[ ]

Specify data type

@DynamoEntity()
class Cat {
    @DynamoProperty({ keyType: KeyType.hash })
    id!: number;

    @DynamoProperty({
        keyType: KeyType.attr,
        dataType: DataType.S   // <<<
    })
    name!: string;

    constructor(id: number, name: string) {
        this.id = id;
        this.name = name;
    }
}

Scalar-data-type does not need to be specified.

[number, string, Boolean, Buffer] are inferred to [N, S, BOOL, B] respectively.

Nested entity

Only classes with @DynamoEntity be nested with DataType.M.

For example,

It will formationed as,

Array

Only classes with @DynamoEntity be list-element with DataType.L, sourceDataType.

For example,

It will formationed as,

Set

For example,

It will formationed as,

Last updated

Was this helpful?