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
已提問 1 年前檢視次數 1154 次
1 個回答
1
已接受的答案

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
專家
已回答 1 年前
  • OK thanks. I thin this TypeORM alternative looks pretty good!

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南