Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | 9x 9x 9x 9x 9x 9x 9x 9x 3x 3x 3x 3x 3x 3x | import { DocumentClient } from 'aws-sdk/clients/dynamodb';
import { Transaction } from '../types.d';
import { unmarshallTransaction } from './schema/tableSchema';
import { DynamodbUtils } from '../common_services/dynamodb/dynamodbUtils';
const dynamodbUtils = new DynamodbUtils();
/**
* map the attributes name different between database and Transaction interface
*/
const dbToTransactionNameMapping: { [key: string]: string } = {
id: 'deviceUuid',
transactionUuid: 'id',
};
/**
* The attributes in database which don't exit in Transaction
*/
const attributesToDelete = ['type', 'transactionUuid', 'panToken', 'par'];
export const convertDbItemToTransaction = (
item: DocumentClient.AttributeMap,
): Transaction => dynamodbUtils.convertDbItemToDto<Transaction>(
item,
dbToTransactionNameMapping,
attributesToDelete,
);
export const convertDbStreamToTransaction = (record: {
dynamodb: { NewImage: DocumentClient.AttributeMap };
}): Transaction => {
const { dynamodb } = record;
const { NewImage: newImage } = dynamodb;
console.log('new Image ', newImage);
console.log('new Image string', JSON.stringify(newImage));
const transaction: any = unmarshallTransaction(newImage);
return convertDbItemToTransaction(transaction)
};
|