Created
September 15, 2020 23:01
-
-
Save SoftwareDevPro/a9945279229ffc7a33dc86b396cd09fd to your computer and use it in GitHub Desktop.
Query an item from an AWS DynamoDb table
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
| async function query (table, kce, eav) { | |
| const params = { | |
| TableName: table, | |
| KeyConditionExpression: kce, | |
| ExpressionAttributeValues: eav | |
| } | |
| try { | |
| let result = await ddb.query(params).promise() | |
| return result | |
| } catch (error) { | |
| console.error(error) | |
| } | |
| } | |
| const item = query('table', 'userId = :id ', { ':id': 'johnDoe' }) | |
| console.log(item) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment