> For the complete documentation index, see [llms.txt](https://aerocode.gitbook.io/tynamo/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://aerocode.gitbook.io/tynamo/tynamo-1/mapper/formation-api/formationmap.md).

# formationMap

### Spec

```typescript
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      |

{% hint style="warning" %}
An error is occurs, if the `source` is null or undefined.
{% endhint %}

### Example

```typescript
@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,

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