Skip to content

Instantly share code, notes, and snippets.

@SoftwareDevPro
Created September 15, 2020 23:01
Show Gist options
  • Select an option

  • Save SoftwareDevPro/a9945279229ffc7a33dc86b396cd09fd to your computer and use it in GitHub Desktop.

Select an option

Save SoftwareDevPro/a9945279229ffc7a33dc86b396cd09fd to your computer and use it in GitHub Desktop.
Query an item from an AWS DynamoDb table
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