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
feita há um ano1154 visualizações
1 Resposta
1
Resposta aceita

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
ESPECIALISTA
respondido há um ano
  • OK thanks. I thin this TypeORM alternative looks pretty good!

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas