Nullable
Define nullable property
You can define property as nullable.
@DynamoEntity()
class Cat {
@DynamoProperty({ keyType: KeyType.hash })
id!: number;
@DynamoProperty({ keyType: KeyType.sort })
age!: number;
@DynamoProperty({
keyType: KeyType.attr,
nullable: true // <<<
})
name?: string;
constructor(id: number, age: number, name?: string) {
this.id = id;
this.age = age;
this.name = name;
}
}
HASH
and SORT
should not be nullable.
For example,
const badCat: Cat = new Cat(0, 1);
const dynamo: AttributeMap = Mapper.formation(badCat, Cat);
It will formationed as,
{
"id": {
"N": "0"
},
"age": {
"N": "1"
},
"name": {
"NULL": true // <<<
}
}
Last updated
Was this helpful?