Records inserted into DynamoDb via typedORM have incorrect Entity info

Viewed 177

When I insert records into my local dynamoDb table via typeDORM in a lambda, it inserts the record with the wrong entity information. For example the GSI1PK

GSI1: {
        partitionKey: 'PRO#{{primary_key}}',
        sortKey: 'PRO#{{primary_key}}#YEAR#{{year}}',
        type: INDEX_TYPE.GSI,
    },

of a Pro record should be (and is when run the code as an individual node file) PRO#PROCUREMENT_2022 but when I run the same code as a lambda it saves the GSI1PK as an IdList entity LIST#PROLIST_2022. I was able to find out that depending on which Entity I added last in my typedORM.createConnection function, that was the where the GSI1PK information would be built. Is there a reason that the createConnection function is giving different results when the code is run from a lambda vs as a standalone node file?

createConnection({
        entities    : [Procurement, IdList],
        name        : 'default',
        table       : testTable,
    }) ;

This code works when it is run as a standalone node file and is able to handle the Procurement and IdList entities at the same time.

1 Answers

@Greesemonkey3

Hi, This is the creator of TypeDORM. There should not be any difference in the behavior when running it inside of a stand-alone node server or in lambda.The entity inserted should always be the same regardless of runtime chosen.

Can you please raise this as an issue in the official github repository, so that it can be tracked better?

Related