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!

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则