Created
May 30, 2019 08:39
-
-
Save alex-samborskiy/43062365c3de737cc0d7527b38d115e3 to your computer and use it in GitHub Desktop.
[DynamoDB get last added item] #DynamoDB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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