# Differences from Dynamo

### Differences from Dynamo

Most `Tynamo API` and `Dynamo API` are similar, including input formats and output formats. However, to reduce the unnecessary work of Dynamo, Tynamo has several differences:

* It is not necessary to explicitly name the table.\
  Because use the table information stored in `@DynamoEntity`.\
  Therefore, the following parameters are deleted and not used.
  * TableName<br>
* Legacy conditional parameters in the Dynamo API are no longer used.\
  Only expressions are allowed.
  * See:  [Legacy Conditional Paramets](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.html)<br>
* All param of `AttributeMap` changed to `@DynamoEntity` type.\
  The list is as follow.
  * Item
  * Key
  * ExpressionAttributeValues
  * ...<br>
* Automatically inserts the name of the class member or expression value used in the `expression`.\
  Check [here](https://aerocode.gitbook.io/tynamo/expression/differences-from-dynamo) for more information.

### Redesign example

Among the Dynamo APIs, input and output of `putItem` methods are as follows.

{% tabs %}
{% tab title="Input" %}
{% code title="PutItemInput.ts" %}

```typescript
export interface PutItemInput {
    TableName: TableName;
    Item: PutItemInputAttributeMap;
    Expected?: ExpectedAttributeMap;
    ReturnValues?: ReturnValue;
    ReturnConsumedCapacity?: ReturnConsumedCapacity;
    ReturnItemCollectionMetrics?: ReturnItemCollectionMetrics;
    ConditionalOperator?: ConditionalOperator;
    ConditionExpression?: ConditionExpression;
    ExpressionAttributeNames?: ExpressionAttributeNameMap;
    ExpressionAttributeValues?: ExpressionAttributeValueMap;
}    
```

{% endcode %}
{% endtab %}

{% tab title="Output" %}
{% code title="PutItemOutput.ts" %}

```typescript
export interface PutItemOutput {
    Attributes?: AttributeMap;
    ConsumedCapacity?: ConsumedCapacity;
    ItemCollectionMetrics?: ItemCollectionMetrics;
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

By the design principle of Tynamo, it is changed as follows:

{% code title="TynamoPutItemInput.ts" %}

```typescript
export interface TynamoPutItemInput<TSource> {
    // TableName: TableName;   <<< TableName
    // Item: PutItemInputAttributeMap;   <<< Changed to @DynamoEntity 
    // Expected?: ExpectedAttributeMap;  <<< Legacy parameter
    // ExpressionAttributeValues?: ExpressionAttributeValueMap;  <<< Changed to @DynamoEntity
    // ConditionalOperator?: ConditionalOperator;  <<< Legacy parameter
    Item: TSource;
    ValueItem?: any;
    ReturnValues?: ReturnValue;
    ReturnConsumedCapacity?: ReturnConsumedCapacity;
    ExpressionAttributeNames?: ExpressionAttributeNameMap;
    ReturnItemCollectionMetrics?: ReturnItemCollectionMetrics;
    ConditionExpression?: ConditionExpression;
}
```

{% endcode %}

{% code title="TynamoPutItemOutput.ts" %}

```typescript
export interface TynamoPutItemOutput<TSource> {
    // Attributes?: AttributeMap;   <<< Changed to @DynamoEntity
    Attributes?: TSource;
    ConsumedCapacity?: ConsumedCapacity;
    ItemCollectionMetrics?: ItemCollectionMetrics;
}
```

{% endcode %}

Most of the TynamoAPIs are designed as above.
