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

  • Legacy conditional parameters in the Dynamo API are no longer used. Only expressions are allowed.

  • All param of AttributeMap changed to @DynamoEntity type. The list is as follow.

    • Item

    • Key

    • ExpressionAttributeValues

    • ...

  • Automatically inserts the name of the class member or expression value used in the expression. Check here for more information.

Redesign example

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

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

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

TynamoPutItemInput.ts
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;
}
TynamoPutItemOutput.ts
export interface TynamoPutItemOutput<TSource> {
    // Attributes?: AttributeMap;   <<< Changed to @DynamoEntity
    Attributes?: TSource;
    ConsumedCapacity?: ConsumedCapacity;
    ItemCollectionMetrics?: ItemCollectionMetrics;
}

Most of the TynamoAPIs are designed as above.

Last updated

Was this helpful?