Mapping Concept

Depending on the value type or the meta data provided from decorators, values are mapped to DynamoDB attributes.

As long as there are no decorators the mapper decides by the value type, to which DynamoDB attribute type it will map.

We map all properties (Object.getOwnPropertyNames(objectToMap)) by default. Use the @Transient decorator to prevent a property from being mapped.

Empty Values

(null & undefined) are treated as empty values and are not mapped to an attribute value.

JS value
{
    "name": null,
    "age": 23,
    "nationality": undefined
}
DynamoDB value
{
    "age": {N: "23"} 
}

Without Decorator

*Binary is not yet supported

Avoid using Set for types other than string|number|Binary without decorator. In this case make sure to add the@CollectionProperty({opt})

Set<CustomType> would be mapped implicitly to [L]ist of [M]aps. But when parsing the Attribute from DynamoDB, there's no information about the Set and will therefore be parsed to an array. To fix this, use the @CollectionProperty() decorator.

With Decorator

*If CustomType is string|number|Binary, it will be mapped to the respective [S]et

Generic information is never available due to some serialization limitations of the typescript compiler. Therefore you can provide the itemType to the @CollectionProperty decorator.

Last updated