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
질문됨 일 년 전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
전문가
답변함 일 년 전
  • OK thanks. I thin this TypeORM alternative looks pretty good!

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인