0

I am trying to scan a DynamoDB table which may be more than 1 MB, so I'm using ExclusiveStartKey. I've been going through all the examples in How to fetch/scan all items from `AWS dynamodb` using node.js but I'm getting an error in this line: scanParams.ExclusiveStartKey = items.LastEvaluatedKey;

src/services/DynamoDB.ts:33:18 - error TS2339: Property 'ExclusiveStartKey' does not exist on type '{ TableName: any; }'.

33       scanParams.ExclusiveStartKey = items.LastEvaluatedKey;
                    ~~~~~~~~~~~~~~~~~


Found 1 error.

This kind of makes sense because the scanParams usually have just the table name and no other keys. So, how do I get rid of this error?

Sh4dy
  • 143
  • 2
  • 15

1 Answers1

2

Hint the shape of params to Typescript:

const params = {
  TableName: tableName,
  ExclusiveStartKey: undefined, // <-- add this
};

Or, if you want to get really fancy, import and use the library's defined type. If you are using the doc client from SDK v3, for example:

import {ScanCommandInput} from '@aws-sdk/lib-dynamodb'

const params: ScanCommandInput = {
  TableName: tableName,
};
fedonev
  • 20,327
  • 2
  • 25
  • 34