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
}