DynamoDB Data Mapper, SDK v3

0

Does anybody know if AWS Labs Datamapper works with @aws-sdk/client-dynamodb? When I try, for example, to do a mapper.scan() I get:

"errorMessage": "this.client.scan(...).promise is not a function",

like it's looking for a .promise() method, when client.scan() already returns a promise. The calling point causing this is ScanPaginator.ts#L27

this.client = new DynamoDB({});
this.mapper = new DataMapper({
    client: this.client
})

I think the reason for this mayhem is that dynamodb-data-mapper was designed for aws-sdk 2.7 and never updated for v3. I found some really old documentation that sort of explains what's going on:

By default, the AWS SDK for JavaScript will check for a globally defined Promise function. If found, it adds the promise() method on AWS.Request objects.

so I think the gist of all this is that it's trying to make scan() async even though in v3 it already is. Since this is typescript can anybody think of a workaround? Perhaps extend the v3 DynamoDB client to add a .promise() method that does nothing?

profile picture
wz2b
asked a year ago1132 views
1 Answer
1
Accepted Answer

The dynamodb-data-mapper-js package has not been updated for a number of years and I would strongly advise against taking a dependency on it if you intend to use JS V3.

profile pictureAWS
EXPERT
answered a year ago
  • OK thanks. I thin this TypeORM alternative looks pretty good!

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions