Skip to content

Instantly share code, notes, and snippets.

@alex-samborskiy
Created May 30, 2019 08:39
Show Gist options
  • Select an option

  • Save alex-samborskiy/43062365c3de737cc0d7527b38d115e3 to your computer and use it in GitHub Desktop.

Select an option

Save alex-samborskiy/43062365c3de737cc0d7527b38d115e3 to your computer and use it in GitHub Desktop.
[DynamoDB get last added item] #DynamoDB
const params = {
TableName: TASKS_TABLE_NAME,
KeyConditionExpression: '#account_id = :account_id and begins_with(#sort_key, :sort_key)',
ExpressionAttributeNames: {
'#account_id': 'account_id',
'#sort_key': 'sort_key'
},
ExpressionAttributeValues: {
':account_id': `account_id=${accountId}`,
':sort_key': `changelog#${taskSortKey}`
},
Limit: 1,
ScanIndexForward: false
};
const {Items} = await ddb.query(params).promise();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment