I just want to ask you, how can I receive the newest items sorted by ASC by created date.
const getItems = async (limit) => {
const params = {
TableName,
KeyConditionExpression: '#field = :value',
ExpressionAttributeNames: {
'#field': 'pk',
},
ExpressionAttributeValues: {
':value': 'ITEM'
},
Limit: 3,
ScanIndexForward: true, // I think that it will sort by date, but it's probably sorting by pk...
};
return results.Items;
};
How can I receive 3 newest created items with dynamodb documentClient?
Thank you for help!