0

Quick one I hope. I have a GSI on a table with a pk (composite string CAMP#g56gd-6…) and a sk (timestamp 166637384). When I apply ScanIndexForward to the query as true, it always returns the results in descending order.

Also a side issue is it doesn't seem to set the applied Limit to the results. Always returns the full list of matched items. Any ideas?

const campaignIdParams: DynamoDB.DocumentClient.QueryInput = {
  TableName: Table.CAMPAIGNS,
  IndexName: TableIndexes.CAMPAIGNS.skCreatedAt,
  KeyConditionExpression: 'sk = :sk',
  ExpressionAttributeValues: {
    ':sk': parsedSK,
  },
  ProjectionExpression: 'pk',
  ScanIndexForward: sortDir.localeCompare('<') === 0 ? false : true,
  ReturnConsumedCapacity: 'TOTAL',
  Limit: +limit
}
Ryan Carville
  • 355
  • 7
  • 15
  • How is your timestamp sort column formatted? Can you provide sample examples? What datatype is the sk attribute. – Stagg Jun 23 '21 at 15:30
  • Sure @Stagg timestamps are a Unix timestamp (number) and the sk (pk for the index) is a composite string ‘CAMP#ei8js-he86b-b87j-8778fb’ – Ryan Carville Jun 23 '21 at 18:29

0 Answers0