formationMap

Spec

formationMap<TSource>(
    source: TSource, 
    TClass: ClassCapture<TSource>
): { M: MapAttributeValue }

Convert DynamoEntity to AttributeValue(M).

Input

Name

Type

Information

source

TSource

Entity to convert to AttributeValue(M).

TClass

ClassCapture<TSource>

Reference of @DynamoEntity class

An error is occurs, if the source is null or undefined.

Example

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

    @DynamoProperty({ keyType: KeyType.attr })
    name!: string;
}
const badCat :Cat = {
    id: 666,
    name: "garfield"
};
const dynamo : AttributeMap = Mapper.formation(badCat, Cat);

It will be formationed as,

{
    "M": {
        "id": {
            "N": "666"
        },
        "name": {
            "S": "garfield"
        }
    }
}

Last updated